首先獲取快取的大小
/**
* create by mazhanzhu on 2019/3/21
*/public class datacleanmanager
return getformatsize(cachesize);
}/**
* 清除快取
*/public static void clearallcache(context context)
}private static boolean deletedir(file dir) }}
return dir.delete();
}// 獲取檔案大小
--> sdcard/android/data/你的應用的包名/files/ 目錄,一般放一些長時間儲存的資料
--> sdcard/android/data/你的應用包名/cache/目錄,一般存放臨時快取資料
public static long getfoldersize(file file) throws exception else
}} catch (exception e)
return size;
}/**
* 格式化單位
*/public static string getformatsize(double size)
double megabyte = kilobyte / 1024;
if (megabyte < 1)
double gigabyte = megabyte / 1024;
if (gigabyte < 1)
double terabytes = gigabyte / 1024;
if (terabytes < 1)
bigdecimal result4 = new bigdecimal(terabytes);
return result4.setscale(2, bigdecimal.round_half_up).toplainstring() + "tb";
}}
然後清除快取
//清除快取
datacleanmanager.clearallcache(context);
Thinkphp清除快取檔案
thinkphp的快取在開發中是非常煩人的,因為有的時候因為快取的問題而出現的錯誤是非常難找的。刪除快取更是麻煩,還要去資料夾下刪除 如果是linux開發伺服器的話還要登陸伺服器進行刪除。所以這個時候用php命令刪除thinkphp的快取是非常不錯的選擇。cacheaction.class.php ...
ios 清除快取檔案
獲取快取檔案的大小 由於快取檔案存在沙箱中,我們可以通過nsfilemanager api來實現對快取檔案大小的計算。計算單個檔案大小 float filesizeatpath nsstring path return 0 計算目錄大小 清理快取檔案 同樣也是利用nsfilemanager api進...
清除電腦快取的bat檔案
電腦在使用了之後,會產生垃圾快取,若不及時清理會降低電腦的執行速度。1 步驟 2 新建乙個記事本檔案,命名 系統清理 或其他名字 3 原封不動複製下面的文字到該記事本中 echo off echo 正在清除系統垃圾檔案,請稍等.del f s q systemdrive tmp del f s q ...