Search code examples
c#visual-studio-2012windows-phone-8storageapplication-data

Application Data c# win mobile 8 not working as described


I'm trying to set up local settings so I can store data in my Windows Mobile 8 app. The first step I'm trying is:

ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;

Just having that in my code causes the app to fail when debugging on my device.

Any ideas why?

I have "using Windows.Storage;" set. The actual code doesn't throw up any errors.


Solution

  • I needed to use the IsolatedStorageSettings feature, as below:

    IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
    
                if (!settings.Contains("test"))
                {
                    settings.Add("test", urlText.Text);
                }
                else
                {
                    settings["test"] = urlText.Text;
                }
                settings.Save();