[1].[代码] 删除保存于手机上的缓存. 跳至 [1] [2] [3]
02 | private int clearCacheFolder(File dir, long numDays) { |
04 | if (dir!= null && dir.isDirectory()) { |
06 | for (File child:dir.listFiles()) { |
07 | if (child.isDirectory()) { |
08 | deletedFiles += clearCacheFolder(child, numDays); |
10 | if (child.lastModified() < numDays) { |
16 | } catch (Exception e) { |
[2].[代码] 打开关闭使用缓存 跳至 [1] [2] [3]
2 | WebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); |
5 | WebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); |
[3].[代码] 在退出应用的时候加上如下代码 跳至 [1] [2] [3]
01 | File file = CacheManager.getCacheFileBaseDir(); |
02 | if (file != null && file.exists() && file.isDirectory()) { |
03 | for (File item : file.listFiles()) { |
09 | context.deleteDatabase( "webview.db" ); |
10 | context.deleteDatabase( "webviewCache.db" ); |
转载于:https://www.cnblogs.com/hudabing/p/3186004.html