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
Better than using File.separator
is this, which is standard Java:
final File file = new File(Environment.getExternalStorageDirectory()
.getAbsolutePath(), filename);
You can just do this:
File f = new File(Environment.getExternalStorageDirectory()
.getAbsolutePath() + File.separator + fileName);
Better still:
final File file = new File(Environment.getExternalStorageDirectory(), filename);
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");
来源:https://stackoverflow.com/questions/8370665/read-file-from-external-storage