Search code examples
c#windowswindows-8windows-8.1isolatedstorage

Saving lists (String) to application/isolated storage (Win8.1)


I have a list of multiple strings which I would like to save to IsolatedStorage. Doing something obvious like

List<string> l = new List<string>();
ApplicationData.Current.LocalSettings.Values["locations"] = l;

Results in a Data of this type is not supported error.

From my knowledge, an adaptation of this code for WP8 silverlight works fine. What am I doing wrong?


Solution

  • ApplicationData.Current.LocalSettings supports only base data types.

    Thought if you have a simple List<string>, you can make use of Linq:

    List<string> l = new List<string>(); // your list with strings
    ApplicationData.Current.LocalSettings.Values["locations"] = l.ToArray();
    // then when you want to retrive it:
    List<string> lret = ((string[])ApplicationData.Current.LocalSettings.Values["locations"]).ToList();