我正在尝试从文件中读取内容,但检查结果为假。我不明白为什么会发生这种情况,该文件存在我有多个时间只是为了确定。
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
我也已将其包含在 AndroidManifest.xml 文件中,因此这也不是问题。
String filePath = Environment.getExternalStorageDirectory() + "/folder/Save.spm";
File filecheck = new File(filePath);
if(filecheck.exists() == false)
{
return false;
}
FileInputStream file = new FileInputStream(filePath);
DataInputStream input = new DataInputStream(file);
为什么android声称该文件不存在?
最佳答案
您如何检查该文件是否存在?您是否尝试过使用 ADB pull 命令从模拟器中检索文件(如果您使用的是模拟器)?
adb pull /path/to/file
获取文件检查的绝对路径并尝试。您也可能将应用程序缓存目录误认为是外部存储。或者可能有多个外部存储,而您正在寻找错误的存储。
关于java.io.FileNotFoundException : [filepath] (No such file or directory),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12875048/