Skip to content

Instantly share code, notes, and snippets.

@lopspower
Last active May 18, 2024 12:14
Show Gist options
  • Save lopspower/76421751b21594c69eb2 to your computer and use it in GitHub Desktop.
Save lopspower/76421751b21594c69eb2 to your computer and use it in GitHub Desktop.
All Android Directory Path

All Android Directory Path

Twitter

1) System directories

⚠️ We can't write to these folers

Method Result
Environment.getDataDirectory() /data
Environment.getDownloadCacheDirectory() /cache
Environment.getRootDirectory() /system

2) External storage directories

⚠️ Need WRITE_EXTERNAL_STORAGE Permission

Method Result
Environment.getExternalStorageDirectory() /storage/sdcard0
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS) /storage/sdcard0/Alarms
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM) /storage/sdcard0/DCIM
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) /storage/sdcard0/Download
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES) /storage/sdcard0/Movies
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC) /storage/sdcard0/Music
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_NOTIFICATIONS) /storage/sdcard0/Notifications
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) /storage/sdcard0/Pictures
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PODCASTS) /storage/sdcard0/Podcasts
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_RINGTONES) /storage/sdcard0/Ringtones

3) Application directories

Method Result
getCacheDir() /data/data/package/cache
getFilesDir() /data/data/package/files
getFilesDir().getParent() /data/data/package

4) Application External storage directories

Method Result
getExternalCacheDir() /storage/sdcard0/Android/data/package/cache
getExternalFilesDir(null) /storage/sdcard0/Android/data/package/files
getExternalFilesDir(Environment.DIRECTORY_ALARMS) /storage/sdcard0/Android/data/package/files/Alarms
getExternalFilesDir(Environment.DIRECTORY_DCIM) /storage/sdcard0/Android/data/package/files/DCIM
getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS) /storage/sdcard0/Android/data/package/files/Download
getExternalFilesDir(Environment.DIRECTORY_MOVIES) /storage/sdcard0/Android/data/package/files/Movies
getExternalFilesDir(Environment.DIRECTORY_MUSIC) /storage/sdcard0/Android/data/package/files/Music
getExternalFilesDir(Environment.DIRECTORY_NOTIFICATIONS) /storage/sdcard0/Android/data/package/files/Notifications
getExternalFilesDir(Environment.DIRECTORY_PICTURES) /storage/sdcard0/Android/data/package/files/Pictures
getExternalFilesDir(Environment.DIRECTORY_PODCASTS) /storage/sdcard0/Android/data/package/files/Podcasts
getExternalFilesDir(Environment.DIRECTORY_RINGTONES) /storage/sdcard0/Android/data/package/files/Ringtones

📚 Best Android Gists

You can see other best Android Gists or offer your just here https://github.com/lopspower/BestAndroidGists 👍.

@sauliko
Copy link

sauliko commented Nov 25, 2020

Is there way to write under storage but not in sdcard0?

@cmaked
Copy link

cmaked commented Apr 13, 2022

@sauliko sdcard0 is the internal phone's storage, to write to external sd cards: https://stackoverflow.com/questions/40068984/universal-way-to-write-to-external-sd-card-on-android

@aeroxr1
Copy link

aeroxr1 commented May 16, 2023

Can we crete own folder in /storage/sdcard0/Android/data/package/files in the following way:

val myTestFolder = File(getExternalFilesDir(null), "testFolder")
myTestFolder.mkdirs()

?

Because on Android documentation :
"Note: On Android 11 (API level 30) and higher, apps cannot create their own app-specific directory on external storage."

https://developer.android.com/training/data-storage/app-specific#external-access-files

@mohammednawas8
Copy link

Thanks for this informative gist

@MinaGaylord
Copy link

MinaGaylord commented Feb 12, 2024

I am looking for the best android gists online and I am glad I found your post where I found my answer. I appreciate you for sharing it with us. Now, I would like to help you because you helped me too. If you are looking for a site online through which you can buy college papers then I would like to suggest you to visit https://academized.com/buy-college-papers-online here where you will find professional essay writers who will help you with your essay assignments. If you are not so good at writing an essay assignment then you can take help from the given website.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment