2012-09-17 74 views
0

我有一个基于PhoneGap 2.0的移动应用程序,它使用LocalStorage。我的Android 2.3.3设备上的本地存储似乎像sessionStorage一样工作,即信息被保存并且只能在应用关闭之前使用。当我重新启动应用程序时,信息消失了。Android上的PhoneGap - localStorage不工作

我访问这样的/存储的信息:在部署到WP7手机(使用window.localStorage)

function onDeviceReady() 
{ 
    if(typeof(Storage)!=="undefined") 
    { 
     if(localStorage.getItem("test") != null) 
     { 
      alert(localStorage.getItem("test")); 
     } 
     ... 
     localStorage.setItem("test", "test Value"); 
    } 
} 

同样的解决办法正常工作。我尝试过和没有“窗口”。字首。在显示之前,我也尝试将localStorage中的值分配给全局变量,正如某些线程所建议的,没有运气。

回答

0

这适用于我在Phonegap 2.1发布候选版,Nexus 7运行4.1.1和运行2.3.3的仿真器上。你正在测试什么设备?

这可能是2.0版本中的一个bug,虽然我在bug跟踪器中没有看到类似的东西。试用2.1.0,看看会发生什么?

+0

我在2.3.3模拟器上试过这个,但它似乎并没有工作。我打开我的应用程序,确保localStorage得到更新,然后我转到Android菜单并手动停止应用程序。当我重新打开它时,locaStorage是空的 – filip