1.
                Log.i("sss",getFilesDir().getAbsolutePath());                Log.i("sss",getExternalFilesDir(null).getAbsolutePath());                Log.i("sss",getCacheDir().getAbsolutePath());                Log.i("sss",getExternalCacheDir().getAbsolutePath());

2.输出

07-05 11:23:29.592 27138-27138/hnq.myapplication I/sss: /data/user/0/hnq.myapplication/files07-05 11:23:29.597 27138-27138/hnq.myapplication I/sss: /storage/emulated/0/Android/data/hnq.myapplication/files07-05 11:23:29.598 27138-27138/hnq.myapplication I/sss: /data/user/0/hnq.myapplication/cache07-05 11:23:29.602 27138-27138/hnq.myapplication I/sss: /storage/emulated/0/Android/data/hnq.myapplication/cache
3.重点:

getFileDir() ,返回的文件目录下的文件只有本应用才能读写。

getExternalFile,返回的文件目录下的文件全局都能读写。

 举例:app更新时,把apk文件下载到前一个目录中,安装时会弹出解析软件包出现问题,就是因为没有权限读写。

             下载到后者目录中时,可以弹出安装界面。

更多相关文章

  1. Android文件操作IO技术
  2. Android将Uri转化为文件路径的方法
  3. 解决TabLayout+viewpager 滑动切换时 布局文件不是从头显示
  4. android之sax解析xml文件
  5. [Android]关于filed 遍历资源文件的排序问题
  6. android打开各种文件的类
  7. Android 扫描音乐文件、两种方式获取文件最新修改时间
  8. android 文件保存方法 sd卡中或系统

随机推荐

  1. Android - under the hood
  2. android创建通知栏(java版)
  3. Android学习笔记(7)————Android中的
  4. android电量状态获取
  5. 多线程例子 android camera capture
  6. Android各类路径获取方式
  7. android Progressbar浣跨敤
  8. android 对话框实例
  9. ViewPager fragment android tab选项卡的
  10. Android生命周期的学习