HTML5 本地存储不持久
该网站用于搭载 Gingerbread 操作系统的 Samsung Galaxy Tab。到目前为止使用的浏览器是普通浏览器和 Dolphin HD。当用户进出网络覆盖范围时,本地存储中的项目似乎会随机消失。存储似乎也无法完全承受浏览器崩溃或设备重新启动的影响。奇怪的是,存储通常不会完全清除,只是大量物品丢失。其他人听说过这个问题或有什么建议吗?
编辑:我所说的本地存储是指,
localStorage["Key"] = value;
检索使用:
localStorage.getItem("Key");
在每种情况下,在添加到本地存储后,站点都能够检索和使用数据。但是,在此之后的某个时间(通常是在漫游或浏览器/平板电脑崩溃后),数据将不再存在。我发现的所有内容都表明本地存储应该持续存在,所以我真的不知道从这里去哪里。
Site is used on Samsung Galaxy Tab with the Gingerbread OS. Browsers used so far are the stock browser as well as Dolphin HD. Items in local storage seem to at random disappear when users go in and out of network coverage. Storage also seems to not be able to fully survive browser crashes or device restarts. Weird part is storage doesn't usually clear out completely, just a large number of items go missing. Anyone else heard of this problem or have any suggestions?
Edit: By local storage I mean,
localStorage["Key"] = value;
Retrived using:
localStorage.getItem("Key");
In every case, directly after adding to local storage, the site is able to retrieve and use the data. However, sometime after this usually after roaming or browser/tablet crashes, the data is no longer there. Everything I've found says local storage should persist, so I don't really know where to go from here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
进一步调试一下怎么样?也许您自己的代码以某种方式覆盖了它?
我在 PhoneGap 中使用 localStorage/sessionStorage 并且从未让它们消失...
添加以下事件处理程序:
每次访问存储时都会触发(并登录到桌面浏览器上的控制台)。您还可以记录更多详细信息,以便在 adb logcat 中查看(例如正在访问的密钥!)
看看 此 stackoverflow 问题,了解有关存储事件的更多详细信息。
How about debugging this a bit further? Maybe your own code is somehow overwriting it?
I am using localStorage/sessionStorage in PhoneGap and never had them disappearing...
Add the following event handler:
Which will fire (and log to console, on desktop browser) every time the storage is accessed. You could also log more detailed info to be seen in your adb logcat (like the key being accessed!)
Have a look at this stackoverflow question for more details on Storage events.