skip to Main Content

I’m getting the following error only on Android 11 and above.

Steps to reproduce:

  1. Save a file to '/storage/emulated/0/Download/fileName.pdf'
  2. Uninstall the app and install it again.
  3. Save a file to the same path.

Error:

FileSystemException: Cannot open file, path = '/storage/emulated/0/Download/fileName.pdf' (OS Error: Permission denied, errno = 13)

If I try to delete the file:

 PathNotFoundException: Cannot delete file, path = '/storage/emulated/0/Download/fileName.pdf' (OS Error: No such file or directory, errno = 2)

Any help would be greatly appreciated.

2

Answers


  1. android:requestLegacyExternalStorage="true" in application in Manifest file.

    Can you try this?

    Login or Signup to reply.
  2. I had the same problem and used the solution on stackoverflow here: downloads_path_provider — OS Error: Permission denied, errno = 13

    The accepted answer plus the modification posted by Ramkesh Yadav worked for me.
    It does require the MANAGE_EXTERNAL_STORAGE permission though, so might not work for you. Posting here in case others with this issue (like me) land on this question.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search