开发者

localStorage alternative for Phonegap

I tried using localStorage and globalStorage for storing small amounts of data locally in the browser(from local page), but got security exception with globalStorage a开发者_StackOverflow中文版nd the data didn't persist with localStorage.

Cookies are too small and using files and databases seems like overkill and may be unstable across platforms. Do I really have to use files or databases to store ~20kb of data? Are there alternatives to localStorage or other ways to work around this issue?


I had no problem getting this small sample to persist data between application launches in the iPhone 4.3 simulator.

function onDeviceReady() {
    //window.localStorage.setItem("key", "value");

    var value = window.localStorage.getItem("key");

    navigator.notification.alert(value);
}

Uncomment to set the initial value, then comment it out to test persistence on subsequent launches.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜