ApplicationDataContainer values can be: bool, byte, int, uint, long, ulong, float, double, or string

using Windows.Storage;
Write Settings

	//----- STORE APP SETTINGS -----
	ApplicationDataContainer AppDataLocalSettings = ApplicationData.Current.LocalSettings;

	AppDataLocalSettings.Values["MyInt"] = 5;
	AppDataLocalSettings.Values["MyBool"] = true;
	AppDataLocalSettings.Values["MyString"] = "Hello";
Read Settings

Null is returned if setting does not exist

	//----- READ APP SETTINGS -----
	int SomeInt;
	bool SomeBool;
	string SomeString;
	object ReadValue;

	ApplicationDataContainer AppDataLocalSettings = ApplicationData.Current.LocalSettings;

	ReadValue = AppDataLocalSettings.Values["MyInt"];
	if (ReadValue != null)
		SomeInt = (int)ReadValue;

	ReadValue = AppDataLocalSettings.Values["MyBool"];
	if (ReadValue != null)
		SomeBool = (bool)ReadValue;

	ReadValue = AppDataLocalSettings.Values["MyString"];
	if (ReadValue != null)
		SomeString = (string)ReadValue;
Delete Settings

	//----- DELETE AN APP SETTING -----
	ApplicationDataContainer AppDataLocalSettings = ApplicationData.Current.LocalSettings;

Usage Notes

The name of each setting can be 255 characters in length at most. Each setting can be up to 8K bytes in size.

We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.


Your email address will not be published.