Tallboy
Tallboy

Reputation: 13407

Is getExternalFilesDir() private?

I'm trying to store music files users can download with my application, but I don't want them to be publicly visible to 99% of users (I'm excluding rooted devices or special cases)

I'm not worried about the people that go above and beyond to get the audio out by using special tools or a rooted phone.

I am trying to understand the docs but it's not 100% clear to me that getExternalFilesDir() is good to use for that purpose.

Also, the library I'm currently using uses the following line:

Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath()

Is this 100% interchangeable if I just replace it with...

Environment.getExternalFilesDir(Environment.DIRECTORY_MUSIC).getAbsolutePath()

(notice I changed both the directory function, as well as the DIRECTORY type (from PICTURES to MUSIC)

Thanks

Upvotes: 2

Views: 933

Answers (3)

CommonsWare
CommonsWare

Reputation: 1006644

Is getExternalFilesDir() private?

No. Any user and any app (with READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE) can access external storage.

Is this 100% interchangeable if I just replace it with..

That won't compile due to imbalanced parentheses. Also, the values are different (PICTURES versus MUSIC). Ignoring that, it is "interchangeable" insofar as they will both work and will both be on external storage. However, they are not the same thing. The first one is the user's standard PICTURES directory; the second one is a directory dedicated for pictures that is unique to your app. Also, the former requires WRITE_EXTERNAL_STORAGE on all devices; the latter requires it only for Android 4.3 and below.

I don't want them to be publicly visible to 99% of users (I'm excluding rooted devices or special cases)

Use internal storage (e.g., getFilesDir()).

Upvotes: 2

greenapps
greenapps

Reputation: 11214

Use getFilesDir() instead. Thats private app memory.

Upvotes: 1

Reza Nazeri
Reza Nazeri

Reputation: 315

if you put "." before folder name this folder be hidden e.g:

String root = Environment.getExternalStorageDirectory().toString();
File myDir = new File(root + "/.myFolderName");

Upvotes: 0

Related Questions