Read file from external storage

I just can't find how to get one specified file from external storage. I know that with getExternalStoragePublicDirectory () you get the external repository directory, but I cannot get it any further. I need some method where you have to specify the file name and it returns the file. Thanx

+6
source share
3 answers

Better than using File.separator , this is standard Java:

 final File file = new File(Environment.getExternalStorageDirectory() .getAbsolutePath(), filename); 
+15
source

You can simply do this:

 File f = new File(Environment.getExternalStorageDirectory() .getAbsolutePath() + File.separator + fileName); 
+4
source

Even better:

 final File file = new File(Environment.getExternalStorageDirectory(), filename); 
0
source

Source: https://habr.com/ru/post/903013/


All Articles