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

ファイルは SD カードにあるのに、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 に答える