我想检查给定的文件是否存在于 android sd 卡中。我正在尝试使用绝对路径创建文件并使用 file.exists()
检查但它不起作用。该文件的 URL 是 "file:///mnt/sdcard/book1/page2.html"
并且该文件确实存在。但不知何故 file.exists()
并没有显示相同的内容。
最佳答案
File extStore = Environment.getExternalStorageDirectory();
File myFile = new File(extStore.getAbsolutePath() + "/book1/page2.html");
if(myFile.exists()){
...
}
这应该有效。
关于android - 如何检查sd卡目录下是否存在文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11292359/