问题
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
回答1:
Better than using File.separator
is this, which is standard Java:
final File file = new File(Environment.getExternalStorageDirectory()
.getAbsolutePath(), filename);
回答2:
You can just do this:
File f = new File(Environment.getExternalStorageDirectory()
.getAbsolutePath() + File.separator + fileName);
回答3:
Better still:
final File file = new File(Environment.getExternalStorageDirectory(), filename);
回答4:
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