grizzly grizzly - 1 month ago 13
Android Question

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

Kai Kai
Answer

You can always create a folder for your app in the Downloads folder. It will always be there. You can access it via Environment.getExternalStoragePublicDirectory(Environment.DI‌​RECTORY_DOWNLOADS). And since you are saving files, it makes it even a more appropriate place to store it, don't you think so?