I simply cannot find how to get one specified file from the external storage. I know that with getExternalStoragePublicDirectory(), you get the external storage directory but I can't get further. I need some kind of method where you have to give the name of the file and it returns the file. Thanx
Asked
Active
Viewed 4.0k times
4 Answers
24
Better than using File.separator
is this, which is standard Java:
final File file = new File(Environment.getExternalStorageDirectory()
.getAbsolutePath(), filename);

J. B. Rainsberger
- 1,193
- 9
- 23
-
if you get file path at specific name then what happen with file – Adnan haider May 06 '21 at 06:54
-
I'm sorry, but I don't understand the question. – J. B. Rainsberger Jun 04 '21 at 15:31
6
You can just do this:
File f = new File(Environment.getExternalStorageDirectory()
.getAbsolutePath() + File.separator + fileName);

Chris
- 22,923
- 4
- 56
- 50
3
Better still:
final File file = new File(Environment.getExternalStorageDirectory(), filename);

gisHermit
- 121
- 1
0
I also use getExternalStoragePublicDirectory() and everything goes well. My filename is "DE Disimpan"
File file = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
File filepath = new File(file,"DE Disimpan");

Jhoan River
- 88
- 5