Farzad
Farzad

Reputation: 2090

Android Understand Storage Paths

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

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) :(

Please help me.Thanks

Upvotes: 0

Views: 130

Answers (2)

Farzad
Farzad

Reputation: 2090

Environment.getExternalStorageDirectory() GOOD WORKING.

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

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

Upvotes: 0

Zhi Kai
Zhi Kai

Reputation: 1587

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?

Upvotes: 1

Related Questions