1) Try using setAppCacheEnabled and setAppCacheMaxSize to limit the cache size to very little , lower cache size will result in faster cleanup.
Ex: wv.getSettings().setAppCacheMaxSize(1);
OR
2) If you don't need the cached data then simply set setCacheMode(WebSettings.LOAD_NO_CACHE); , which means
"Don't use the cache, load from the network", even though data is cached.
In-short, simply ignore the cached data, android will take care of it.
OR
3) you can also try the below code for no-caching,
Note: this is only available for Android API 8+
Map<String, String> noCacheHeaders = new HashMap<String, String>(2);
noCacheHeaders.put("Pragma", "no-cache");
noCacheHeaders.put("Cache-Control", "no-cache");
view.loadUrl(url, noCacheHeaders);
OR
4) Clear the cache every-time whenever page load finishes.
Something like this in the WebViewClient
.
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
view.clearCache(true);
}
OR
5) You can try deleting whole cached database at once.
context.deleteDatabase("webview.db");
context.deleteDatabase("webviewCache.db");
This might give a bit faster result, hope so.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…