简体   繁体   中英

Storage not persistent using Ionic Storage

I am attempting to utilize the Ionic Storage library to keep track of settings for my app. However, I am having an issue where each time the app is restarted, the storage is wiped. At least, it appears that way.

I'm storing the data:

this.storage.set('language', 'es');

and attempting to retrieve:

this.storage.get('language').then((val) => {
      this.mylang = val;
    }).catch((errorGet: any) => {
      console.error(errorGet);
      return;
    });

Retrieving the data works if I don't quit the app. But if I quit and re-open, the data is gone. It is using SQLite as far as I can tell (per debug messages in XCode when building & testing there).

I think it's an issue with Ionic-storage, you can check the issue here https://github.com/ionic-team/ionic-storage/issues/165 try to implement another solution SQLite or local storage

The best way is to use back-end for persistent storage like Rest Full API or a database. In this way you can manage the storage problem(This is my suggestion).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM