简体   繁体   中英

java.io.FileNotFoundException: [filepath] (No such file or directory)

I'm trying to read from a file but i'm getting false on the check. I can't see why this is happning, The file exist i have a multible time just to be sure.

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

I also have included this in the AndroidManifest.xml file so that is not the problem either.

    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);

Why does android claim that the file does not exist?

How did you check that the file exists ? Have your tried using the ADB pull command to retrieve the file back from the emulator (if you are using one) ?

adb pull /path/to/file

Get the absolute path for filecheck and try that. It is also possible that you are mistaking the application cache directory with the external storage. Or may be there is more than one external storage and you are looking at the wrong one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM