I’m getting the following error only on Android 11 and above.
Steps to reproduce:
- Save a file to
'/storage/emulated/0/Download/fileName.pdf'
- Uninstall the app and install it again.
- 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
android:requestLegacyExternalStorage="true"
inapplication
in Manifest file.Can you try this?
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.