我正在尝试清除存储在使用 cordova webview 的 android 应用程序中的缓存。
我尝试过cordovaWebView.clearCache(true);
还尝试过
public void deleteCache(Context context) {
Log.i("Utility", "deleting Cache");
try {
File dir = context.getCacheDir();
if (dir != null && dir.isDirectory()) {
deleteDir(dir);
}
} catch (Exception e) {
Log.e("Utility", " exception in deleting cookies");
}
}
public static boolean deleteDir(File dir) {
if (dir != null && dir.isDirectory()) {
String[] children = dir.list();
for (int i = 0; i < children.length; i++) {
boolean success = deleteDir(new File(dir, children[i]));
if (!success) {
return false;
}
}
} else if (dir != null && dir.isFile()) {
dir.delete(); // delete the file INSIDE the directory
}
Log.i("Utility", "deleting Cache " + dir.delete());
return true;
}
但两者都不起作用。
我可以为此找到任何解决方案吗,就像在网络视图中用户用来登录一样,因此我们需要在第二次加载应用程序时清除缓存。
我正在使用“cordova-plugin-cache-clear”插件
https://github.com/anrip/cordova-plugin-cache-clear
要使用该插件,只需调用window.CacheClear(success, error);
它会清理 webView 缓存。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)