Android 获取cache缓存的目录路径

转发请备注原文地址: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();      }   }}

本文出自 “全栈开发” 博客,请务必保留此出处http://andy2290.blog.51cto.com/13193207/1956031

相关文章