Search code examples
c#.netwindows-phone-7application-settings

Do I need to call IsolatedStorageSettings.Save method in windows phone application?


From the remarks section of IsolatedStorageSettings.Save Method page:

Data written to the IsolatedStorageSettings object is saved when the application that uses the class is closed. This can occur when the user closes the Web browser, refreshes a page, or browses away from the page. If you want your application to write to isolated storage immediately, you can call the Save method in application code.

So, I can never call the Save method and every setting will be in safety. I'm just curious in what usecases should I use the Save method?


Solution

  • You have to call IsolatedStorageSettings.Save yourself. As mentioned in the 'Tips and Warnings' section at the bottom of the class reference page, you have to save it yourself in order to make sure it's written to the file.

    The IsolatedStorageSettings class is not automatically saved to disk when values are written. Saves are done in a finalizer, which is usually but not always run when the application shuts down. To ensure saves are actually performed we need to call the Save method after each write or set of writes.