当应用停止使用Sencha Touch 2.2和Phonegap时,LocalStorage商店不会在Android手机上保留

Tod*_*nce 2 android local-storage sencha-touch-2 cordova

这在我的浏览器中工作正常,但当我在手机上安装应用程序并使用它...它看起来很好直到我强制它停止并重新打开应用程序然后我的所有记录都消失了.

我使用2.2和Phonegap ....任何帮助将非常感激.这是我的商店:

Ext.define('MyApp.store.Presentations', {
    extend: 'Ext.data.Store',

    config: {
        model: 'MyApp.model.Presentations',
        sorter: 'title',
        grouper: function (record) {
            var upperCased = record.get('title')[0].toUpperCase();
            return upperCased; //First letter of the title - how we GROUP these
        },
        autoLoad: true,
        proxy: {
            type: 'localstorage',
            id: 'presentations'
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

我这样保存:

var newPresentation = { title: prezTitle, content: '' };
            Ext.getStore('Presentations').add(newPresentation);
            var newRecord = Ext.getStore('Presentations').sync();
Run Code Online (Sandbox Code Playgroud)

小智 8

您可以尝试将以下代码添加到DroidGap类:

super.appView.getSettings().setAllowFileAccess(true);        
super.appView.getSettings().setDatabaseEnabled(true);
super.appView.getSettings().setDatabasePath("/data/data/" + appView.getContext().getPackageName() + "/databases/");
super.appView.getSettings().setDomStorageEnabled(true);
Run Code Online (Sandbox Code Playgroud)

这条线解决了我遇到的同样问题