open failed: EBUSY (Device or resource busy)

后端 未结 7 2060

I have a strange error in my App.

In my app it is possible to download a zipFile, read the content as what it is and also delete it. Its doesn\'t matter what exactly

7条回答
  •  旧时难觅i
    2020-12-24 12:19

    I have a big Answer!! The Problem comes from the Android System or/and the FAT32 system. I can not explain how the system gets the error, it has something to do with deleting files and the FAT32 System.

    But the solution is really easy: Before you delete a Directory or File: rename it!

    Code to rename:

    final File to = new File(file.getAbsolutePath() + System.currentTimeMillis());
    file.renameTo(to);
    to.delete();
    

    That's it, if you rename the folder or file before you delete it, there is no chance for the system to try to open an existing file again or an open file which you want to save again (or something like this).

提交回复
热议问题