android webview setappcacheenabled,关于android的webview的缓存设置
File sdcache = getExternalCacheDir();WebSettings webSettings = webview.getSettings();webSettings.setJavaScriptEnabled(true);webSettings.setAllowFileAccess(true);webSettings.setAppCachePath(sdcache.toS
File sdcache = getExternalCacheDir();
WebSettings webSettings = webview.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setAllowFileAccess(true);
webSettings.setAppCachePath(sdcache.toString());
webSettings.setAppCacheEnabled(true);
webSettings.setAppCacheMaxSize(1024*1024*10);
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ONLY);
webview.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub
return super.shouldOverrideUrlLoading(view, url);
}
@Override
public void onPageFinished(WebView view, String url) {
// TODO Auto-generated method stub
super.onPageFinished(view, url);
}
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
// TODO Auto-generated method stub
//super.onReceivedSslError(view, handler, error);
}
});
代码如上面写的 设置了缓存的路径SD卡的(manifest中配置了权限) 路径为:/storage/sdcard0/Android/data/com.example.webviewtest/cache 服务端用的是html5的application cache 那个玩意 在配置了 当我把缓存模式设置成使用本地缓存的时候 网页就加载不错来 报错net::ERR_CAHCE_MISS应该是网页没有被缓存到本地吧 去对应的路径下找也没有缓存的东西 ,请问这是什么情况啊
更多推荐
所有评论(0)