LocalStorage store not persisting on Android phone

2019-04-02 07:47发布

问题:

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