不需要请求存储权限保存文件的使用方式:
//判断外部存储是否可用
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
// getExternalCacheDir,getExternalFilesDir
getExternalCacheDir() = /sdcard/Android/data/包名/cache
getExternalFilesDir(“test”) = /sdcard/Android/data/包名/files/test
getExternalFilesDir(null) = /sdcard/Android/data/包名/files
} else {
// 无外部存储:
// getFilesDir(),getFilesDir
getCacheDir()方法用于获取 /data/data/包名/cache目录
getFilesDir()方法用于获取 /data/data/包名/files目录
}