文件路径:/storage/emulated/0/DCIM/Camera/IMG_20180705_150703.jpg
1由 fileprovider提供的content类型的uri:
content://com.zlzxm.baselibrary.fileprovider/root_path/storage/emulated/0/DCIM/Camera/IMG_20180705_150703.jpg
2.由Uri.fromfile得到的file类型的uri :
file:///storage/emulated/0/DCIM/Camera/IMG_20180705_150703.jpg
3.选择图片返回content类型的uri:
content://com.miui.gallery.open/raw/%2Fstorage%2Femulated%2F0%2FDCIM%2FCamera%2FIMG20180703102321.jpgpickphoto
路径:
内部存储:
Environment.getDataDirectory() /data
Environment.getDownloadCacheDirectory() /cache
Environment.getRootDirectory() /system
Environment.getDataDirectory().getParentFile()就是根目录,这个目录下还有一些私密的数据,比如:databases(数据库)、shared_prefs(SharedPreferences)等
context.getFilesDir() /data/data/< package name >/files/…
context.getCacheDir() :/data/data/< package name >/cach/…
外部存储:
外部存储又分为SD卡和扩展卡内存
获取路径方式是Environment.getExternalStorageDirectory() /storage/sdcard0
1.Environment.getExternalStoragePublicDirectory(DIRECTORY_ALARMS) /storage/sdcard0/Alarms
2.Environment.getExternalStoragePublicDirectory(DIRECTORY_DCIM) /storage/sdcard0/DCIM
3.Environment.getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS) /storage/sdcard0/Download
4.Environment.getExternalStoragePublicDirectory(DIRECTORY_MOVIES) /storage/sdcard0/Movies
5/Environment.getExternalStoragePublicDirectory(DIRECTORY_MUSIC) /storage/sdcard0/Music
6.Environment.getExternalStoragePublicDirectory(DIRECTORY_NOTIFICATIONS) /storage/sdcard0/Notifications
7.Environment.getExternalStoragePublicDirectory(DIRECTORY_PICTURES) /storage/sdcard0/Pictures
上面的九个方法对应的就是SD卡的九大公有目录,Google官方建议我们数据应该存储在私有目录下,不建议存储在公有目录下或其他地方(6.0需要动态权限)
那什么是私有目录呢?
就是在外部存储的App的包名下,如:/storage/emulated/0/Android/data/cwj.test(包名)/files/test (不需要动态权限 配置了权限就行)
1.getExternalFilesDir() /storage/emulated/0/Android/data/cwj.test(包名)/files/test
2/getExternalCacheDir /storage/emulated/0/Android/data/cwj.test(包名)/cache/test