locked
Is HTML5 Storage persistent across deployment?

Answers

  • If by "persisted across deployment" you mean installing, uninstalling, and reinstalling the app, then this is by design. HTML5 localStorage is saved within the app's appdata folders, as is WinRT local/roaming/temp storage. All that is blown away when you uninstall an app, so it won't be there when you reinstall.

    One exception to this is that roaming state (the < 100K amount that is stored in the cloud), isn't automatically removed the moment you uninstall an app. I've been told that this hangs out in the cloud "for a reasonable amount of time" which is a few weeks, apparently. So if you need that kind of mechanism, that's one option.

    Otherwise, it sounds more like you're working with user data rather than app settings. But if not, then a user will expect the app to be reset if they uninstall and reinstall. If you keep some settings around, then you might offer a means in your Settings panel to reset everything to defaults.

    .Kraig

    • Marked as answer by Ronald Widha Sunday, May 06, 2012 3:51 PM
    Sunday, May 06, 2012 3:40 AM
  • Yes, Windows.Storage.ApplicationData is also deleted when the app is uninstalled. This is one way that Metro style apps guarantee a clean uninstall by default: since appdata is the only place the app can write to openly (without declaring another capability), a developer has to think more before writing artibrary data elsewhere on the file system. This, typically, is why apps leave little bits and pieces around, even when uninstalled--they just forget to delete those bits.

    And yes, HTML5 localStorage uses the same appdata location (the local folder, I believe...been a while since I tried it). You can use both APIs side by side, but they work indepedently and don't read/write each other's data.

    As for best practice, you can really use either. The one caveat is HTML5 localStorage is subject to the usual storage limit that IE places on web apps (10MB...I looked it up). Windows.Storage is only limited by the space on the file system. I'll look up the exact numbers when I'm on my other laptop later.


    Sunday, May 06, 2012 2:17 PM

All replies

  • If by "persisted across deployment" you mean installing, uninstalling, and reinstalling the app, then this is by design. HTML5 localStorage is saved within the app's appdata folders, as is WinRT local/roaming/temp storage. All that is blown away when you uninstall an app, so it won't be there when you reinstall.

    One exception to this is that roaming state (the < 100K amount that is stored in the cloud), isn't automatically removed the moment you uninstall an app. I've been told that this hangs out in the cloud "for a reasonable amount of time" which is a few weeks, apparently. So if you need that kind of mechanism, that's one option.

    Otherwise, it sounds more like you're working with user data rather than app settings. But if not, then a user will expect the app to be reset if they uninstall and reinstall. If you keep some settings around, then you might offer a means in your Settings panel to reset everything to defaults.

    .Kraig

    • Marked as answer by Ronald Widha Sunday, May 06, 2012 3:51 PM
    Sunday, May 06, 2012 3:40 AM
  • Thanks. That's exactly what I meant Kraig. I have several more follow up question on this:

    1. Since Windows.Storage (local and roaming) is saved within the AppData folders, I assume they would have the same behavior. i.e. content will be blown away when app is uninstalled?
    2. Is Html5 localStorage uses the same storage space as Windows.Storage local AppData? can I access the content from both API? or do they work independently? If they are different, what is considered a best practice to use Html5 localStorage or Windows.Storage's local storage? I'm keen to keep my app as close to the web standards as possible for portability reasons.

    Thanks

    R

    Sunday, May 06, 2012 7:30 AM
  • Yes, Windows.Storage.ApplicationData is also deleted when the app is uninstalled. This is one way that Metro style apps guarantee a clean uninstall by default: since appdata is the only place the app can write to openly (without declaring another capability), a developer has to think more before writing artibrary data elsewhere on the file system. This, typically, is why apps leave little bits and pieces around, even when uninstalled--they just forget to delete those bits.

    And yes, HTML5 localStorage uses the same appdata location (the local folder, I believe...been a while since I tried it). You can use both APIs side by side, but they work indepedently and don't read/write each other's data.

    As for best practice, you can really use either. The one caveat is HTML5 localStorage is subject to the usual storage limit that IE places on web apps (10MB...I looked it up). Windows.Storage is only limited by the space on the file system. I'll look up the exact numbers when I'm on my other laptop later.


    Sunday, May 06, 2012 2:17 PM