通常情况下多数应用程序都会将缓存的位置选择为 /sdcard/Android/data/<application package>/cache 这个路径。
选择在这个位置有两点好处:
第一,这是存储在SD卡上的,因此即使缓存再多的数据也不会对手机的内置存储空间有任何影响只要SD卡空间足够就行。
第二,这个路径被Android系统认定为应用程序的缓存路径,当程序被卸载的时候,这里的数据也会一起被清除掉,这样就不会出现删除程序之后手机上还有很多残留数据的问题。
//路径例如: /SD卡/Android/data/程序的包名/cache/uniqueName
private static File getDiskCacheDir(Context context, String uniqueName) {
String cachePath;
if (Environment.MEDIA_MOUNTED.equals(Environment
.getExternalStorageState())
|| !Environment.isExternalStorageRemovable()) {
cachePath = context.getExternalCacheDir().getPath();
} else {
cachePath = context.getCacheDir().getPath();
}
return new File(cachePath + File.separator + uniqueName);
}

最新文章

  1. mysql二级索引
  2. Phylab2.0 文档汇总
  3. 设置DIV块元素在浏览器页面中垂直居中
  4. 3.2 一般的哈尔空间Vj
  5. 数据结构 C++ 单链表 一元多项式的相加
  6. readonly背景色(css)
  7. oracle的基本概念
  8. zoj 2358,poj 1775 Sum of Factorials(数学题)
  9. nopCommerce的源代码结构和架构
  10. ACM Sdut 2158 Hello World!(数学题,排序) (山东省ACM第一届省赛C题)
  11. Servlet 第六课: Session的使用
  12. 512M内存机器如何用好Mysql
  13. 第七届河南省赛10403: D.山区修路(dp)
  14. [Android文档翻译]设备兼容性
  15. .Net 更容易的使用配置文件 SuperConfig
  16. Codeforces Round #410 (Div. 2)
  17. java使用*导包的性能
  18. python接口自动化(一)--什么是接口、接口优势、类型(详解)
  19. 第四节:跨域请求的解决方案和WebApi特有的处理方式
  20. 爬虫_拉勾网(selenium)

热门文章

  1. swprintf has been changed to conform with the ISO C standard, adding an extra character count parameter.
  2. HDU1074(状态压缩DP)
  3. html格式
  4. css样式 -- 表格不会因为字体过长导致字体溢出的问题
  5. 8个超炫的 Web 效果
  6. shell脚本 列出所有网卡的ip地址
  7. SqlServer规则
  8. Git之忽略提交 .gitignore
  9. 零基础配置Linux服务器环境
  10. Weekly Contest 78--------&gt;810. Chalkboard XOR Game