最近在使用WebView来开发,但是遇到个问题就是缓存清除不掉,偶在网上找了好久各种方式的办法都没有效果。包括
File file = CacheManager.getCacheFileBaseDir();
if (file.exists() && file.isDirectory()) {
for (File f : file.listFiles())
f.delete();
}
webview.clearHistory();
webview.clearFormData();
mContext.deleteDatabase("webview.db");
mContext.deleteDatabase("webviewCookiesChromium.db");
mContext.deleteDatabase("webviewCache.db");
webview.loadDataWithBaseURL(null, "","text/html","utf-8",null);
后来在一个帖子中找到个方式实验成果了
CookieManager cm = CookieManager.getInstance();
cm.removeSessionCookie();
cm.removeAllCookie();
http://bbs.51cto.com/thread-834369-1-1.html