2013-04-26 65 views
2

时,LocalStorage商店不会持久保留在Android手机上这在我的浏览器中工作正常,但是当我在手机上安装应用程序并使用它时,它看起来不错,直到我强制它停止并重新打开应用程序,然后我所有的记录都消失了。当应用程序停止使用Sencha Touch 2.2和Phonegap

即时通讯使用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(); 

回答

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

这行已经解决了同一我得到的问题

+0

BOOM!而已!谢谢!!! – 2013-04-30 16:49:20

+0

嗯我是一个在android phonegap noob,这是否意味着我不得不重建lib /如何将此添加到我的droidgap类? – Hessius 2013-05-02 11:11:58

+1

哦nvm将它添加到我的onCreate中的appname.java文件,它的工作:D – Hessius 2013-05-02 13:29:15

相关问题