Android WebView 清理缓存
2020-01-31 本文已影响0人
圣剑Jay
private void clearCache(){
File file = getCacheDir().getAbsoluteFile();//删除缓存
deleteFile(file);
}
public void deleteFile(File file) {
if (file.exists()) {
if (file.isFile()) {
file.delete();
} else if (file.isDirectory()) {
File files[] = file.listFiles();
for (int i = 0; i < files.length; i++) {
deleteFile(files[i]);
}
}
file.delete();
}
}