Logger.i("1、" + Environment.getRootDirectory()
+ ";2、" + Environment.getDataDirectory()
+ ";3、" + Environment.getDownloadCacheDirectory()
+ ";4、" + Environment.getExternalStorageDirectory()
+ ";5、" + Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES)
+ ";6、" + App.getInstance().getContext().getExternalFilesDir(null)
+ ";7、" + App.getInstance().getContext().getFilesDir()
+ ";8、" + App.getInstance().getContext().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)
+ ";9、" + App.getInstance().getContext().getExternalCacheDir()
+ ";10、" + App.getInstance().getContext().getCacheDir()
+ ";11、" + App.getInstance().getContext().getFileStreamPath("custom1")
+ ";12、" + App.getInstance().getContext().getObbDir()
+ ";13、" + App.getInstance().getContext().getDir("custom2", Context.MODE_PRIVATE)
);
编号 | 方法 | 路径 | 备注 |
---|---|---|---|
1 | Environment.getRootDirectory() | /system | |
2 | Environment.getDataDirectory() | /data | |
3 | Environment.getDownloadCacheDirectory() | /cache | |
4 | Environment.getExternalStorageDirectory() | /storage/emulated/0 | |
5 | Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES) | /storage/emulated/0/Movies | |
6 | App.getInstance().getContext().getExternalFilesDir(null) | /storage/emulated/0/Android/data/com.prprlive.gugu/files | |
7 | App.getInstance().getContext().getFilesDir() | /data/data//data/data/com.prprlive.gugu/files | |
8 | App.getInstance().getContext().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS) | /storage/emulated/0/Android/data/com.prprlive.gugu/files/Download | |
9 | App.getInstance().getContext().getExternalCacheDir() | /storage/emulated/0/Android/data/com.prprlive.gugu/cache | |
10 | App.getInstance().getContext().getCacheDir() | /data/data/com.prprlive.gugu/cache | |
11 | App.getInstance().getContext().getFileStreamPath(“custom1”) | /data/data/com.prprlive.gugu/files/custom1 | |
12 | App.getInstance().getContext().getObbDir() | /storage/emulated/0/Android/obb/com.prprlive.gugu | |
13 | App.getInstance().getContext().getDir(“custom2”, Context.MODE_PRIVATE) | /data/data/com.prprlive.gugu/app_custom2 |
待完善:getDatabasePath(String Name),getNoBackupFilesDir(),getCodeCacheDir(),后两个是API21新增的方法
以上内容中Logger.i
是自己封装的Log打印方法,App.getInstance().getContext()
是Application中提供的Context
测试机型:模拟器 系统:Android 5.1.1 在不同的系统上面获取到的路径可能存在差异。