angular - 重建应用程序后,Ionic Native Storage 不会持续存在

标签 angular typescript ionic-framework ionic3 cordova-nativestorage

我正在使用 ionic 3 native 存储并存储如下值:

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

然后我重建应用程序并尝试获取该值,但它返回 null:

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

结果是:我的值:null

不确定为什么这样做不是存储假设将其存储在数据库中,所以我是否重建应用程序应该无关紧要?

最佳答案

您需要安装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

关于angular - 重建应用程序后,Ionic Native Storage 不会持续存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47338009/

相关文章:

根据先前的结果订阅多个 http 请求的 Angular RxJS 最佳实践

css - Chart.js donut Canvas 填充

angular - 使用 Angular 4、Webpack 2、Karma 和 Jasmine 获得单元测试覆盖率

angular - 使用自定义类型 Angular 验证输入

angular - 在 Angular 8 : : ASSERTION ERROR: NgModule 'MyReportsGridComponent' is not a subtype of 'NgModuleType' 中实现延迟加载时出错

javascript - 不使用 angular 中的 javascript 在 div 上设置属性值

angular - 如何使用 typescript 根据 Angular 4 中的某些条件为 html 标签动态添加属性

html - div 上的 ionic 背景 img 不加载本地镜像,但从互联网 url 加载图像

angular - 在 IONIC Ion-Select 上是 'selecting' all options on choice

typescript - 从 firebase 检索用户配置文件数据并显示