I have an app where I capture/download images and store them to the app specific storage using:
File fileToSave = new File(getApplicationContext().getExternalFilesDir(
Environment.DIRECTORY_PICTURES), "filename");
Then, I save the absolute path to the file in the db using:
saveToDb(fileToSave.getAbsolutePath())
My question is, will I be able to access the file later using this absolute path?
File file = new File(savedAbsolutePath);
Is this the best practice?
CodePudding user response:
will I be able to access the file later using this absolute path?
Yes, assuming the user did not delete it or something.
Is this the best practice?
If you want the user to have some ability to access the content independently of your app, using getExternalFilesDir()
is a fine choice.
If you do not want the user to have independent access to the content, you could use getFilesDir()
instead.