2012-09-17 45 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