问题
I have created many apps for Windows Phone 7 and 8. To store settings I was using these methods:
IsolatedStorageSettings.ApplicationSettings["key"] = value;
IsolatedStorageSettings.ApplicationSettings.Save();
Everything worked perfectly, my settings were stored. Save()
method did the job.
But now I am creating an app for Windows Phone 8.1 (WinRT). I have followed this guide to learn hot to save settings. Ane here is how it looks like now:
Windows.Storage.ApplicationData.Current.LocalSettings.Values["key"] = value;
But when I close the app and run again, they're gone, my settings are not stored. So my question is: How to save settings in Windows Phone 8.1?
回答1:
This line really works:
Windows.Storage.ApplicationData.Current.LocalSettings.Values["key"] = value;
The problem is when you're trying to call it via binding in XAML as a property. Then you may have problem with it. Just avoid it, and call this method in code behind explicite.
来源:https://stackoverflow.com/questions/30560722/local-settings-in-windows-phone-8-1-app-are-not-stored