獲取快取大小,清除快取,網上找的,留著備用

2021-07-23 19:21:05 字數 1143 閱讀 4574

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;

} /**

* 格式化單位**

@param

size

*@return

*/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";}

}

Glide獲取快取大小以及清除快取

compile com.github.bumptech.glide glide 3.7.0 呼叫工具類獲取快取大小 string cachesize glidecacheutil.getinstance getcachesize this clean.settext cachesize dingwe...

Android獲取快取大小和清除快取功能

拿去可以直接用 一 清除資料都有哪些 1 file 普通檔案儲存,對應路徑 data data com.files 應用內檔案 得到的方法getfiledir 2 database 資料庫檔案 db檔案 對應路徑 data data com.database 應用資料庫 3 shareprefere...

iOS獲取快取檔案的大小並清除快取

移動應用在處理網路資源時,一般都會做離線快取處理,其中以快取最為典型,其中很流行的離線快取框架為sdwebimage。今天介紹的離線快取功能的實現,主要分為快取檔案大小的獲取 清除快取檔案的實現。nsstring的類別檔案 instancetype cachedir 1.獲取快取檔案的大小 cgfl...