我刚才创建了一个应用程序,我可以在其中读取sdcard中的文件,但是它只打开sdcard中的一个文件,其余的是提供警告
03-26 14:53:33.746: W/System.err(28907): java.
io.FileNotFoundException:/ sdcard / miniclipId:open failed:ENOENT(没有这样的文件或目录)
String filename = editTextFileName.getText().toString();
StringBuffer stringBuffer = new StringBuffer();
String aDataRow = "";
String aBuffer = "";
try {
File myFile = new File("/sdcard/" + filename);
FileInputStream fIn = new FileInputStream(myFile);
BufferedReader myReader = new BufferedReader(
new InputStreamReader(fIn));
while ((aDataRow = myReader.readLine()) != null) {
aBuffer += aDataRow + "\n";
}
myReader.close();
} catch (IOException e) {
e.printStackTrace();
}
Toast.makeText(getApplicationContext
(), aBuffer, Toast.LENGTH_LONG).show();
txt.setText(aBuffer.toString());
}
答案 0 :(得分:1)
/sdcard/
并不意味着真正的sdCard
试试这个。
File myFile = new File(Environment.getExternalStorageDirectory() + filename);