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.
精彩评论