我正在使用 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/