I’m also facing problems where local storage seems to be cleared sometimes. But I cannot reproduce it by home + power reset.
One thing I suspect is that it appears when switching between Xcode debugging and “normal” use of the app … But I’m quite sure it has also appeared when restarting the app after it was regularly installed via iTunes …
Same problem here… we have an app in production and someone say that after about one month all data are cancelled. I don’t have idea how to reproduce this and on our phones android and ios never happened this. Someone found some solutions? I’m planning to switch to sqlite… what do you think about this?
Unfortunately no fix, only the workaround of using file API. I also searched the Cordova JIRA but the only related issues I found were old and closed.
Goal of my current project is to reuse the source of the hybrid app as much as possible for a web app. So sqlite is perhaps not the best way to go. Its also quite complex compared to simple local storage operations.
I’ve been using simple LocalStorage in my app. App has been updated via iTunes multiple times. I can hard reset my phone over and over and never cause local storage to be lost. So, for me and my users, LocalStorage is pretty stable.
People, i have an iphone and it is happening to our app that in production… The ios is cleaning the data… I think that is related with the fact that my iphone hasnot free space.
Localstorage is definitely unstable on iOS. Apple consider it “temporary” storage and can/will clear it without your knowledge.
PhoneGap attempts workarounds for this, but all around you shouldn’t be using it for data you require to be persistent.
Your other browser storage engines:
WebSQL a deprecated web standard. This is supported on iOS and Android, however the latest version of iOS’s WKWebView does not include it so the future isn’t bright.
IndexedDB is the recommended persistent storage engine. However the support in iOS 8 is broken.
Cordova SQLite Plugin exposes an API which is compatible with the WebSQL API - just change calls from window.openDatabase to sqlitePlugin.openDatabase. Boom, persistent storage in a native-backed engine.
Problem with the plugin is you now require Cordova - you can’t test in the browser. So either write your own wrapper function which calls either window or sqlitePlugin depending on the environment, or use an existing wrapper like localForage (forage, not storage).