Search code examples
angulartypescriptionic-frameworkionic3cordova-nativestorage

Ionic Native Storage is not persisting after rebuilding app


I am using ionic 3 native storage and store a value like this:

this.storage.set('myValue', this.value);

Then I rebuild the app and try to get that value and it returns null:

this.storage.get('myValue').then(value => {
console.log('My value: ' + value);
}) 

The result is: My value: null

Not sure why its doing this isn't storage suppose to store it in the database so it should not matter if I rebuild the app or not?


Solution

  • You need to install SQLite plugin.

    When running in a native app context, Storage will prioritize using SQLite, as it's one of the most stable and widely used file-based databases, and avoids some of the pitfalls of things like localstorage and IndexedDB, such as the OS deciding to clear out such data in low disk-space situations.

    ionic cordova plugin add cordova-sqlite-storage