Get Android file path

Environment.getDataDirectory().getPath() : /data

Environment.getDownloadCacheDirectory().getPath() : /cache
Environment.getExternalStorageDirectory().getPath() : /mnt/sdcard
Environment.getRootDirectory().getPath() : /system
Context.getCacheDir().getPath() : /data/data/package name/cache
Context.getExternalCacheDir().getPath() : /mnt/sdcard/Android/data/package name/cache
Context.getFilesDir().getPath( ) : /data/data/package name/files
Context.getObbDir().getPath() : /mnt/sdcard/Android/obb/package name
Context.getPackageName() : package name
Context.getPackageCodePath() : /data/app /application name
Context.getPackageResourcePath() : /data/app/application name/data/data/ This path may be under the application whose package name is "", By calling getFilesDir in a subclass of Context (Activity, Service, etc.).

And /mnt/sdcard/ should be obtained through the getExternalStorageDirectory method of the Environment class on the Android system below 4.0.

In fact, the method getExternalStorageDirectory is better to get the default storage. On different versions of the android system with different settings, the pointing position is not the same. For example, on systems above 4.0, it generally points to "storage/sdcard0" (built-in SD card), but some manufacturers or individuals set it to "storage/sdcard1" (external SD card). Just like windows, the system is usually installed on the C drive, but it can actually be installed on the D drive.

Related: Get Android file path