转发请备注原文地址:https://www.niwoxuexi.com/blog/android00/article/224.html
Android开发中,有时需要知道cache缓存的路径。我写了一个静态类,供大家能参考
public class CommonUtil {/*** 获取cache路径** @param context* @return*/public static String getDiskCachePath(Context context) {if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) || !Environment.isExternalStorageRemovable()) {return context.getExternalCacheDir().getPath();} else {return context.getCacheDir().getPath();}} }