I have an Android browser and I have the option to clear cache, storage, cookies, etc.
The code looks like this:
webView.clearCache(true);
webView.clear
Found the solution:
WebStorage.getInstance().deleteAllData();
I have got a root-access
granted device and found that calling WebStorage.getInstance().deleteAllData();
and similar codes doesn't clear the cache
created by the WebView
at applicationDatadir/app_webview
.
Also, that codes sometimes causes fatal errors like A/libc: Send stop signal to pid:16145 in void debuggerd_signal_handler(int, siginfo_t*, void*)
And it's (the cache) not so small in size.
To achieve that you can use this following code snippet :
public static void clearWebViewCachesCustom(Context context) {
try {
String dataDir = mContext.getPackageManager().getPackageInfo(context.getPackageName(), 0).applicationInfo.dataDir;
new File(dataDir + "/app_webview/").delete();
} catch (Exception e) {
if (!MainActivity.deBugTest) Crashlytics.logException(e);
e.printStackTrace();
e.getSuppressed();
}
}