Storage question doubt


i have this app built with ionic 3 and cordova 8

i use storage framework to store certain files and crypto-js to encrypt them successfully. I understand that storage has 2 ways of storing data, one is plain localstorage (good old html5 localstorage) and another is sqlite. I am using the localstorage, as the data is small

My problem is it seems, I loose the data if I (or may be corrupt the data) if I install a new version on top of it !

is it so, that whatever we store using storage framework, will be lost when we reinstall another version ?

What is the way around ?



If you are using Ionic’s Storage (which is a wrapped localForage library) you are using a persistence solution available to your application context:

  • could be SQLite if cordova app
  • could be localStorage or WebSQL or IndexedDB if web app

SQLite is the only real persistence here as it is not subject to browser quotas (browsers “grant” certain amount of space to each website normally).

As long as your code is not deleting anything from persistence the data should be in there, BUT it really depends on how you implemented the logic for it. So if you could share your particular implementation -the community here can help guide you.

There are also numerous nuances when it comes to web-app context - like if user has incognito mode or if user “installed” your web app as PWA on iOS (then persistence is a brand new sandbox and hence has zero data in it etc). Also if other web-sites use a lot of the space allocated it CAN danage your data.

So simply put - do NOT treat browser based persistence as a real persistence - treat it as a cached data that helps your app to be more offline resilient.