java.io.File cacheDir = getCacheDir(); android.util.Log.d("debug", "cacheDir->" + cacheDir.getPath()); if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.N) { java.io.File dataDir = getDataDir(); android.util.Log.d("debug", "dataDir->" + dataDir.getPath()); } java.io.File filesDir = getFilesDir(); android.util.Log.d("debug", "filesDir->" + filesDir.getPath()); java.io.File xmlDir = getDir("xml", MODE_PRIVATE); android.util.Log.d("debug", "xmlDir->" + xmlDir.getPath()); java.io.File dataDirectory = android.os.Environment.getDataDirectory(); android.util.Log.d("debug", "dataDirectory->" + dataDirectory.getPath()); java.io.File downloadCacheDirectory = android.os.Environment.getDownloadCacheDirectory(); android.util.Log.d("debug", "downloadCacheDirectory->" + downloadCacheDirectory.getPath()); java.io.File rootDirectory = android.os.Environment.getRootDirectory(); android.util.Log.d("debug", "rootDirectory->" + rootDirectory.getPath()); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) { java.io.File storageDirectory = android.os.Environment.getStorageDirectory(); android.util.Log.d("debug", "storageDirectory->" + storageDirectory.getPath()); } java.io.File externalCacheDir = getExternalCacheDir(); android.util.Log.d("debug", "externalCacheDir->" + externalCacheDir.getPath()); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { java.io.File[] externalMediaDirs = getExternalMediaDirs(); if (externalMediaDirs != null && externalMediaDirs.length > 0) { for (java.io.File file : externalMediaDirs) { android.util.Log.d("debug", "遍历外部媒介目录->" + file.getPath()); } } } java.io.File[] externalCacheDirs = getExternalCacheDirs(); if (externalCacheDirs != null && externalCacheDirs.length > 0) { for (java.io.File file : externalCacheDirs) { android.util.Log.d("debug", "遍历外部缓存目录->" + file.getPath()); } }
debug: cacheDir->/data/user/0/com.example.test/cache
debug: dataDir->/data/user/0/com.example.test
debug: filesDir->/data/user/0/com.example.test/files
debug: xmlDir->/data/user/0/com.example.test/app_xml
debug: dataDirectory->/data
debug: downloadCacheDirectory->/data/cache
debug: rootDirectory->/system
debug: storageDirectory->/storage
debug: externalCacheDir->/storage/emulated/0/Android/data/com.example.test/cache
debug: 遍历外部媒介目录->/storage/emulated/0/Android/media/com.example.test
debug: 遍历外部缓存目录->/storage/emulated/0/Android/data/com.example.test/cache
debug: externalStorageDirectory->/storage/emulated/0