我在 android里面 使用html5的 localStorage
为什么存不进去也读不出来呀?
网上搜了好多都没效果
|
1
2
3
4
5
6
7
8
9
|
mainWebView = (WebView)this.findViewById(R.id.mainWebView); WebSettings settings = mainWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setAllowFileAccess(true); settings.setDatabaseEnabled(true); String dir = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); settings.setDatabasePath(dir); settings.setDomStorageEnabled(true); settings.setGeolocationEnabled(true); |
解决方案:
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.getSettings().setAppCacheMaxSize(1024*1024*8);
String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
mWebView.getSettings().setAppCachePath(appCachePath);
mWebView.getSettings().setAllowFileAccess(true);
mWebView.getSettings().setAppCacheEnabled(true);
这个测试了是可以的
转自:http://www.oschina.net/question/111965_108361?sort=time
本文详细探讨了在Android应用中使用WebView时遇到的LocalStorage无法存取的问题,并提供了一套有效的解决方案,包括设置WebView的DOM存储、应用程序缓存路径及权限等关键步骤。
687

被折叠的 条评论
为什么被折叠?



