android webview localStorage无效 android webview 中localStorage无效的解决办法

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

android webview localStorage无效 android webview 中localStorage无效的解决办法

  2021-03-21 我要评论
想了解android webview 中localStorage无效的解决办法的相关内容吗,在本文为您仔细讲解android webview localStorage无效的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点: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);


这个测试了是可以的

猜您喜欢

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们