Reputation: 2434
I have a iOS app built using Ionic (Cordova and Angular). Version 1 of my app (which has been released for a while) stores some data using HTML5 localStorage. I'm ready to release version 2 but updating the app (I've simulated both via xcode, itunes and via a testflight install) wipes all the data stored in localstorage.
It seems the localstorage db is stored in Library/Caches/ if that is helpful.
For info I'm using:
Cordova 3.9.2 and Ionic 1.1.1
After spending all day searching SO and various other sites I'm still no wiser.
Is there a way to prevent this? Interested to hear from anyone using localStorage on a released cordova app.
Upvotes: 3
Views: 3777
Reputation: 1174
This plugin is also saves data using NSUserDefaults (iOS) and SharedPreferences (Android) to store the data permanently.
Upvotes: 0
Reputation: 713
I have used the Cordova SQL Lite plugin which persists to the app's data directory on this disk. This data persists when the app is updated. This is your best bet today since it works well on iOS and Android.
Upvotes: 0
Reputation: 403
As you mentioned the localstorage is stored in Library/Caches. This directory may get cleared by the OS if the system is very low on space (File System Programming Guide).
If the system isn't low on space the data should be available after app updates. We are using localstorage in our app too and having problems with loosing data when the device runs out of space.
After researching I've found a plugin especially for this problem. This plugin is using NSUserDefaults (iOS) and SharedPreferences (Android) to store the data permanently. This is actually my preferred solution for this problem.
Upvotes: 6