How to store a user preference in a Metro App
-
29-10-2019 - |
Question
In Android, you can store user's config in "preferences" file. So where should the "preferences" being stored in a Metro app and how can this be accomplished?
Any example will help. Examples in Javascript would be the best.
Solution
You can use Windows.Storage.ApplicationData for this.
Example:
var applicationData = Windows.Storage.ApplicationData.current;
var userSetting= applicationData.localSettings.values.userSetting;
//First run ? set default value
if (userSetting) == "undefined"){
applicationData.localSettings.values.userSetting= 1;
}
You can also take a look at the Sample SDK app
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow