How can I store or save items of a ListView permanently in the app?


  • Hello there,

    I have a problem and would like to ask you, if you can give me a hint or some code how I can store ListView items permanently for the whole app life cycle.


    1. User start the app first time and will get a lot of listView - items where he can choose some listView - Items as his favourites.

    2. User selects some of the items and sets them as favourite items.

    3. User closes the app (and shuts down the system or anything else).

    4. User starts the app again and wants to see his favourite ListView-Items.

    How can I do this? I tried to store the selected ListView-Items to "Windows.Storage.ApplicationData.current.localSettings.values["favoriteItems"] = items;" but it seems, that the localSettings cannot save complex data types? Is there any other solution? I thought about JSON.stringify-ing that data, but I don't know whether that makes sense or is possible.

    I do not need to use roaming currently, it would be enough to save the data to the local system.

    Wednesday, July 04, 2012 6:56 PM


All replies

  • You can store data in the applications local folder.  See the Write data to file and Read data from file sections here -> http://msdn.microsoft.com/en-us/library/windows/apps/hh465118.aspx

    I did this by JSON.stringify-ing my data and it has been working well for me.

    Dave Paquette @Dave_Paquette www.davepaquette.com

    • Marked as answer by Freimuth Thursday, July 05, 2012 8:19 PM
    Wednesday, July 04, 2012 7:16 PM
  • That worked perfectly for me with stringifying the data. Thank you.

    Before I tried to use localSettings for storing my data, but my data became too large and an exception was thrown.

    Thursday, July 05, 2012 8:20 PM