LocalStorage store not persisting on Android phone when app stops using Sencha Touch 2.2 and Phonegap

故事扮演 提交于 2019-12-21 06:08:09

问题


This is working fine in my browser but when I install the app on my phone and use it ... it looks fine UNTIL I force it to stop and reopen the app and then all my records are gone.

Im using 2.2 and Phonegap.... any help would be VERY appreciated. Here is my store:

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'
        }
    }
});

I save like this:

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

回答1:


You can try by adding the following code to the DroidGap class :

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);

This lines have solved the same problem that i got



来源:https://stackoverflow.com/questions/16240613/localstorage-store-not-persisting-on-android-phone-when-app-stops-using-sencha-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!