1
votes

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
The line above should work (definitely works for me), so a couple of checks to make: 1. define "close the app and run again" - are you closing an emulator? Is Visual Studio delete-ing and re-installing the app you are deploying to a device? 2. Define "value" - what are you trying to store?zigah
I'm not closing the emulator/device, just the app. The value is a short string, like "Nick", nothing fancy.Łukasz Rejman
Have you tried the line above in a new blank project?zigah
No prpblem! Glad it works for you now!zigah
@ŁukaszRejman please add your solution as an answer and accept it. That'll get this question out of the unanswered area.Greg Whatley

1 Answers

3
votes

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.