当应用程序停止使用 Sencha Touch 2.2 和 Phonegap 时,LocalStorage 存储不会保留在 Android 手机上

2024-05-09

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

我正在使用 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'
        }
    }
});

我这样保存:

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

您可以尝试将以下代码添加到 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);

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

当应用程序停止使用 Sencha Touch 2.2 和 Phonegap 时,LocalStorage 存储不会保留在 Android 手机上 的相关文章

随机推荐