Android 4.0 -> 4.3 (included) - Web storage lost between webview pages

我的梦境 提交于 2019-12-03 15:36:44

Between ICS (SDK 15) and JellyBean (SDK 16) there were some changes in the WebView's security model and how it handles javascript from file:// origins. Please try to call

WebSettings.setAllowUniversalAccessFromFileURLs(true)

to acknowledge you are working from file:// URLs and trust the content you are displaying. I imagine that due to the upgrade to Chromium WebView in 4.4 something else changed in the underlying implementation to not require these settings.

I'm sorry to hear that webstorage api has an issue on Android, because I will be using this in next few days.

As you have investigated already, Android 4.4 uses a brandnew WebView which is based on the ChromeBrowser where lot of web technology such as webScoket etc other than localStorage api are already supported well.

Having said that, reading your post claims localStorage api has an issue for android4.0-4.2 (which I also aim as target devices), I thought using FileSystem api instead.

http://www.html5rocks.com/en/tutorials/file/filesystem/

However, looking at web, it is so uncertain if this api works well, and finally I found this.

Using local storage on Android webview

https://github.com/didimoo/AndroidLocalStorage

My understanding is that session storage exists while the window that created it still open and local storage is persistent between sessions. So does the browser treats the window to remain open while navigating between two local files? This could be open to interpretation. Looking at your code it seems fairly easy to change it to use local storage rather than session storage, so would that be an option?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!