Search code examples
androidandroid-sdcardandroid-external-storageandroid-memoryinternal-storage

Android Understand Storage Paths


I want to save file on phone. new File(directory, myCustomFolder).

  • My files are large and MP3

1 - Environment.getExternalStorageDirectory() is not always access to save file. On some phones that don't have sd card not available and return nothing. :(

2 - getFilesDir() after unistall my app my files remove. (Is not the right place to store files) :(

3 - getCacheDir() after unistall my app my files remove. (Is not the right place to store files) :(

4 - getDataDirectory() after unistall my app my files remove. (Is not the right place to store files) :(

  • Now, How do I distinguish the right place and secure and always available to save my files?
  • I need a SD card if there was not, I have my files stored on internal memory and the public(Public means no save to data app folder). ?!!
  • Apps like WhatsApp and Telegram how to make folder into two external memory and internal memory?

Please help me.Thanks


Solution

  • Environment.getExternalStorageDirectory() GOOD WORKING.

    solution is: android API 23+ need check dangerous permission:

    https://developer.android.com/training/permissions/requesting.html