A helper class for Windows Phone and Windows apps to easily save, load and delete data from storage.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
StorageHelper
.gitattributes
.gitignore
LICENSE
README.md

README.md

StorageHelper

StorageHelper is a helper class for Windows Phone and Windows apps to easily save, load and delete data from storage. By default, XML (de)serialization is used, but overrides are available for JSON (de)serialization instead.

How to use

Windows Phone Silverlight

// Use the application state dictionary (temporary storage)
Storage.SaveState("MYKEY", MYOBJ);
Storage.LoadState<TYPE>("MYKEY");
Storage.DeleteState("MYKEY");

// Use the persistent storage (using files)
[await] Storage.SaveAsync("MYKEY", MYOBJ);
[await] Storage.SaveAsync("MYKEY", MYOBJ, true); // use JSON
[await] Storage.LoadAsync<TYPE>("MYKEY");
[await] Storage.LoadAsync<TYPE>("MYKEY", true); // use JSON
[await] Storage.DeleteAsync("MYKEY");

Windows Store (Windows 8.1, Windows Phone 8.1, Universal)

// Use the persistent storage (using files)
[await] Storage.SaveAsync("MYKEY", MYOBJ);
[await] Storage.SaveAsync("MYKEY", MYOBJ, true); // use JSON
[await] Storage.SaveAsync(ApplicationData.Current.LocalFolder, "MYKEY", MYOBJ);
[await] Storage.LoadAsync<TYPE>("MYKEY");
[await] Storage.LoadAsync<TYPE>("MYKEY", true); // use JSON
[await] Storage.LoadAsync<TYPE>(ApplicationData.Current.LocalFolder, "MYKEY");
[await] Storage.DeleteAsync("MYKEY");
[await] Storage.DeleteAsync(ApplicationData.Current.LocalFolder, "MYKEY");

// Use the persistent settings storage (using dictionary)
Storage.SaveSetting("MYKEY", MYOBJ);
Storage.SaveSetting(ApplicationData.Current.LocalSettings, "MYKEY", MYOBJ);
Storage.LoadSetting("MYKEY");
Storage.LoadSetting(ApplicationData.Current.LocalSettings, "MYKEY");
Storage.DeleteSetting("MYKEY");
Storage.DeleteSetting(ApplicationData.Current.LocalSettings, "MYKEY");

Credits

This library has been written by [Rajen Kishna] (https://twitter.com/rajen_k) with input from [Dave Smits] (https://twitter.com/davesmits). This library has been created as a side-project to assist the community and is provided "as is" with no warranty whatsoever and has no relations to our employers (Microsoft and Sparked).