/**
* 打印路径信息
*/
private void printPath() {
System.out.println("-------------------内部存储----------------------");
//主目录
String dataDirectory = Environment.getDataDirectory().getAbsolutePath();
System.out.println("Environment.getDataDirectory():"+dataDirectory);
String cacheDir = getCacheDir().getPath();
System.out.println("getCacheDir():"+cacheDir);
String filesDir = getFilesDir().getPath();
System.out.println("getFilesDir():"+filesDir);
String fileStreamPath = getFileStreamPath("").getPath();
System.out.println("getFileStreamPath:"+fileStreamPath);
String fileStreamPath2 = getFileStreamPath("test").getPath();
System.out.println("getFileStreamPath:"+fileStreamPath2);
System.out.println("-------------------外部存储----------------------");
String externalStorageDirectory = Environment.getExternalStorageDirectory().getPath();
System.out.println("getExternalStorageDirectory():"+externalStorageDirectory);
File externalCacheDir = getExternalCacheDir();
System.out.println("getExternalCacheDir():"+externalCacheDir);
File externalFilesDir = getExternalFilesDir("");
System.out.println("getExternalFilesDir():"+externalFilesDir);
File externalFilesDir2 = getExternalFilesDir("test");
System.out.println("getExternalFilesDir()2:"+externalFilesDir2);
File externalFilesDir3 = getExternalFilesDir(Environment.DIRECTORY_MUSIC);
System.out.println("getExternalFilesDir()3:"+externalFilesDir3);
File externalStoragePublicDirectory1 = Environment.getExternalStoragePublicDirectory("");
System.out.println("getExternalStoragePublicDirectory()1:"+externalStoragePublicDirectory1);
File externalStoragePublicDirectory2 = Environment.getExternalStoragePublicDirectory("test");
System.out.println("getExternalStoragePublicDirectory()2:"+externalStoragePublicDirectory2);
File externalStoragePublicDirectory3 = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC);
System.out.println("getExternalStoragePublicDirectory()3:"+externalStoragePublicDirectory3);
}
// 华为P10 Android7.0
//-------------------内部存储----------------------
// Environment.getDataDirectory(): /data
// getCacheDir(): /data/user/0/com.cvsong.study.dagger2demo/cache
// getFilesDir(): /data/user/0/com.cvsong.study.dagger2demo/files
// getFileStreamPath: /data/user/0/com.cvsong.study.dagger2demo/files
// getFileStreamPath: /data/user/0/com.cvsong.study.dagger2demo/files/test
//-------------------外部存储----------------------
// getExternalStorageDirectory(): /storage/emulated/0
// getExternalCacheDir(): /storage/emulated/0/Android/data/com.cvsong.study.dagger2demo/cache
// getExternalFilesDir(): /storage/emulated/0/Android/data/com.cvsong.study.dagger2demo/files
// getExternalFilesDir()2: /storage/emulated/0/Android/data/com.cvsong.study.dagger2demo/files/test
// getExternalFilesDir()3: /storage/emulated/0/Android/data/com.cvsong.study.dagger2demo/files/Music
// getExternalStoragePublicDirectory()1: /storage/emulated/0
// getExternalStoragePublicDirectory()2: /storage/emulated/0/test
// getExternalStoragePublicDirectory()3: /storage/emulated/0/Music
// 华为畅享5 Android5.1
//-------------------内部存储----------------------
// Environment.getDataDirectory(): /data
// getCacheDir(): /data/data/com.cvsong.study.dagger2demo/cache
// getFilesDir(): /data/data/com.cvsong.study.dagger2demo/files
// getFileStreamPath: /data/data/com.cvsong.study.dagger2demo/files
// getFileStreamPath: /data/data/com.cvsong.study.dagger2demo/files/test
//-------------------外部存储----------------------
// getExternalStorageDirectory(): /storage/emulated/0
// getExternalCacheDir(): /storage/emulated/0/Android/data/com.cvsong.study.dagger2demo/cache
// getExternalFilesDir(): /storage/emulated/0/Android/data/com.cvsong.study.dagger2demo/files
// getExternalFilesDir()2: /storage/emulated/0/Android/data/com.cvsong.study.dagger2demo/files/test
// getExternalFilesDir()3: /storage/emulated/0/Android/data/com.cvsong.study.dagger2demo/files/Music
// getExternalStoragePublicDirectory()1: /storage/emulated/0
// getExternalStoragePublicDirectory()2: /storage/emulated/0/test
// getExternalStoragePublicDirectory()3: /storage/emulated/0/Music
网友评论