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;
	AppDataLocalSettings.Values.Remove("MyString");

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.

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *