手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >android webview 中localStorage无效的解决方法
android webview 中localStorage无效的解决方法
摘要:我在android里面使用html5的localStorage为什么存不进去也读不出来呀?网上搜了好多都没效果复制代码代码如下:ma...

我在 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);

这个测试了是可以的

【android webview 中localStorage无效的解决方法】相关文章:

基于Android中手势交互的实现方法

Android启动模拟器报错解决方法

android实现listview分页的方法

android 中 webview 怎么用 localStorage

Android 将 android view 的位置设为右下角的解决方法

深入android中The connection to adb is down的问题以及解决方法

Android 九宫格的实现方法

Android ViewPager相册横向移动的实现方法

android将搜索引擎设置为中国雅虎无法搜索问题解决方法

Android HttpURLConnection.getResponseCode()错误解决方法

精品推荐
分类导航