android webview 中localStorage无效的解决方法
更新时间:2015年06月01日 11:04:41 投稿:junjie
这篇文章主要介绍了android webview 中localStorage无效的解决方法,本文直接给出解决方法实现代码,需要的朋友可以参考下
我在 android里面 使用html5的 localStorage
为什么存不进去也读不出来呀?
网上搜了好多都没效果
复制代码 代码如下:
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);
这个测试了是可以的
相关文章
关注Ionic底部导航按钮tabs在android情况下浮在上面的处理
Ionic是一款流行的移动端开发框架,但是刚入门的同学会发现,Ionic在iOS和Android的底部tabs显示不一样。在安卓情况下底部tabs会浮上去,下面给大家介绍下实现代码,一起看看吧2016-12-12Android水波纹载入控件CircleWaterWaveView使用详解
这篇文章主要为大家详细介绍了Android水波纹载入控件CircleWaterWaveView使用方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2019-01-01Android webview注入JS代码 修改网页内容操作
这篇文章主要介绍了Android webview注入JS代码 修改网页内容操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2020-03-03
最新评论