开发者

localStorage alternative for Phonegap

开发者 https://www.devze.com 2023-04-05 09:28 出处:网络
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

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

精彩评论

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

关注公众号