Search code examples
cwindows-runtimewindows-phone

Save parameters when application is closed


How do I save parameters before closing my Windows Phone Runtime app and use these parameters when I activate my app? I have a String and an int that I need to save.


Solution

  • You can use LocalSettings for that.

    Use below code to save values in to the settings

    Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
    localSettings.Values["exampleSetting"] = "test";
    

    to retrieve settings use below code

    var value = localSettings.Values["exampleSetting"] as string;
    

    More details available here