Skip to content
Advertisement

getFilesDir() vs getExternalFilesDir(), which one is more recommended?

As far as I’ve noticed, using getFilesDir() to store data (camera captures in my case) is somewhat temporary. I say somewhat because if I close and reopen the app, I’m able to access the directory and files list, but not the file itself.

Is my logic wrong or is that by design? Out of the 2 methods, which is more recommended in :

  1. general
  2. my case (privacy is needed)

Advertisement

Answer

Simply, getFilesDir() refers to internal storage that cannot be accessible outside your application. It’s not explorable by the device as well.

getExternalFilesDir() refers to external storage, it’s a type of App-specific storage. this can be explorable as you find its directory in

data/data/your package name

In general, you may use external storage as internal storage may be limited.

For privacy, if you need you to file security, use getFilesDir() as it’s not accessible outside your application as I mentioned before.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement