1
  File file = new File("file:///storage/sdcard0/myfile.txt");
  if (file.exists()) {
     //...
  }

我看到文件在我的 sdcard 中,但为什么 file.exists() 总是返回 false?

4

2 回答 2

2

尝试不file://

File file = new File("/storage/sdcard0/myfile.txt");
  if (file.exists()) {
     //...
  }
于 2013-07-29T05:25:49.177 回答
0

试试这个-

File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/myfile.txt");
if (file.exists()) {
 //...
}
于 2013-07-29T05:24:11.157 回答