如何从 sdcard 读取特定文件。我已经通过 DDMS 将文件推送到 sdcard 中,我试图通过这种方式读取它,但这给了我异常(exception)。谁能告诉我如何准确地指向那个文件?
我的代码是这样的。
String path = Environment.getExternalStorageDirectory().getAbsolutePath();
FileInputStream iStream = new FileInputStream(path);
最佳答案
您正在尝试读取目录...您需要的是文件!做这样的事情......然后,您可以根据需要读取文件。
File dir = Environment.getExternalStorageDirectory();
File yourFile = new File(dir, "path/to/the/file/inside/the/sdcard.ext");
关于android - 从android中的sdcard读取特定文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3779944/