There’s two ways to use storage in Windows Phone 8 apps:

  • Isolated Storage
  • Windows.Storage

So which one should you use? My recommendation: Windows.Storage.And why? Because Isolated Storage isn’t thread safe.

When the app is small and there’s no 3rd party libraries, you can create a wrapper over the Isolated Storage which uses locking to make sure that only one thread can access the Isolated Storage. But as soon as you add a third party library, you’ll lose control: If the library uses Isolated Storage, it will bypass the locking mechanism you have created inside your storage wrapper.

So, in order to save yourself from random exceptions and strange data losses, prefer Windows.Storage over Isolated Storage.


Comment by Erkki Nokso-Koivisto

I think, one more good reason to prefer Windows.Storage over IsolatedStorage is portability between WP8 and Windows 8 app. IsolatedStorage is not part of Windows Store APIs.

Erkki Nokso-Koivisto
Comment by Nguyen Quy Hy

Hi, can you elaborate more on the problem? Maybe with an example where IsolatedStorage causes problem and ApplicationData does not.

Nguyen Quy Hy
Comment by tehbigone

Windows.Storage is buggy on the phone. I've gotten weird ACCESS DENIED errors, some apis also don't work at all. You will get a not implemented exception @ runtime!. Better to stick with isolatedstorage for stablity until better support rolls out.

Comment by tiwahu

That is interesting. Besides WP8 and W8 portability, which seems like the obvious reason.
Might not need a 3rd-party library to get those random exceptions. Some WP8 SDK media history related and background image update code appears to play in the same storage sandbox; it wouldn't know about a custom locking wrapper either.

Comment by Mikael Koskinen

That's interesting to hear. We have had the same exact experience, but with Isolated Storage :)

Comment by Mikael Koskinen

I prepared the following gist which tries to highlight the problem with Isolated Storage: https://gist.github.com/mikoskinen/9203782

The example code creates few threads and each thread tries to write a new file using Isolated Storage. Even though all the threads are writing to a different file, the code throws Operation not permitted on IsolatedStorageFileStream. This doesn't happen always, but from time to time.

Comment by Mikael Koskinen

Thanks, that's a really good point. Also, I've seen a PCL Storage library (sorry, can't remember the name) which tries to abstract away the implementation details. So you can use the same library from WP, Windows Store and Xamarin tools and the library makes sure that the API stays the same.

Comment by Pedro Lamas

The truth is that both of them have quite a few known issues... but I'm quite curious on why you say that Windows.Storage is thread-safe, though to be honest, I haven't read the docs yet! :)