公共存储目录
Environment.getExternalStorageDirectory(): /storage/emulated/0
Environment.getExternalStoragePublicDirectory(""): /storage/emulated/0
Environment.getExternalStoragePublicDirectory("test"): /storage/emulated/0/test
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES): /storage/emulated/0/Pictures
注:通过拼接File.separator,可以在外部存储上新建任意文件夹(6.0动态权限WRITE_EXTERNAL_STORAGE)
总结常量
public static String DIRECTORY_MUSIC = "Music";
public static String DIRECTORY_ALARMS = "Alarms";
public static String DIRECTORY_NOTIFICATIONS = "Notifications";
public static String DIRECTORY_PICTURES = "Pictures";
public static String DIRECTORY_MOVIES = "Movies";
public static String DIRECTORY_DOWNLOADS = "Download";
public static String DIRECTORY_DCIM = "DCIM";
public static String DIRECTORY_DOCUMENTS = "Documents";
内部存储
根目录 : /data Environment.getDataDirectory()
应用目录 :根目录/xxx/包名(不同设备可能不同) eg:data/data/包名 或 data/user/0/包名
应用缓存目录:应用目录/cache Context.getCacheDir() 程序卸载 或 运行空间不足时 会被清理
应用文件目录:应用目录/files Context.getFilesDir()
应用目录/files Context.getFileStreamPath("")
应用目录/files/aaa Context.getFileStreamPath("aaa")
外部存储
根目录 : /storage/emulated/0(不同设备可能不同)Environment.getExternalStorageDirectory()
应用目录 :根目录/Andorid/data/包名
应用缓存目录:应用目录/cache Context.getExternalCacheDir()
应用文件目录:应用目录/files Context.getExternalFilesDir("") type为空时获取
应用目录/files/aaa Context.getExternalFilesDir("aaa")
应用目录/files/常量(Music) Context.getExternalFilesDir("Environment.DIRECTORY_MUSIC")
网友评论