android 文件目录权限
16lz
2022-04-19
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文件下载到前一个目录中,安装时会弹出解析软件包出现问题,就是因为没有权限读写。
下载到后者目录中时,可以弹出安装界面。
更多相关文章
- android截图代码
- android 调用相册里的图片并返回
- Android将Uri转化为文件路径的方法
- 解决TabLayout+viewpager 滑动切换时 布局文件不是从头显示
- Android文件操作IO技术
- 【笔记】Android开发中从EditText中获取数字
- 一些常用SD卡操作的方法,APk管理之类的方法
- Android(安卓)Support Multidex原理分析
- NPM 和webpack 的基础使用