[英]Storage not persistent using Ionic Storage
I am attempting to utilize the Ionic Storage library to keep track of settings for my app.我正在尝试利用 Ionic Storage 库来跟踪我的应用程序的设置。 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).
据我所知,它正在使用 SQLite(在 XCode 中构建和测试时的调试消息)。
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我认为这是离子存储的问题,您可以在此处查看问题https://github.com/ionic-team/ionic-storage/issues/165尝试实施另一个解决方案 SQLite 或本地存储
The best way is to use back-end for persistent storage like Rest Full API or a database.最好的方法是使用后端进行持久存储,例如 Rest Full API 或数据库。 In this way you can manage the storage problem(This is my suggestion).
通过这种方式,您可以管理存储问题(这是我的建议)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.