首页 > 系统 > Android > 正文

实现Android 获取cache缓存的目录路径的方法

2019-12-12 02:15:19
字体:
来源:转载
供稿:网友

实现Android 获取cache缓存的目录路径的方法

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();   }  }}

如有疑问,请留言或者到本站社区交流讨论,本站关于Android 开发的文章还有很多,希望大家搜索查阅,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表