File file = new File("file:///storage/sdcard0/myfile.txt");
if (file.exists()) {
//...
}
我看到该文件在我的SD卡中,但为什么file.exists()总是返回false?
答案 0 :(得分:1)
尝试不使用file://
File file = new File("/storage/sdcard0/myfile.txt");
if (file.exists()) {
//...
}
答案 1 :(得分:0)
试试这个 -
File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/myfile.txt");
if (file.exists()) {
//...
}