源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

android webview 中localStorage无效的解决方法

  • 时间:2021-07-04 11:14 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:android webview 中localStorage无效的解决方法
我在 android里面 使用html5的 localStorage 为什么存不进去也读不出来呀? [b]网上搜了好多都没效果[/b]
[u]复制代码[/u] 代码如下:
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);
[b]解决方案:[/b]
[u]复制代码[/u] 代码如下:
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);
这个测试了是可以的
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部