Following error in Android application is very annoying and you may waste several hours by hunting the root cause:
It might occur even when the manifest is correct and contains proper permission:
Here is sample code which will pass on file existence check, but the execution will fail on readBytes:
To fix this problem it is necessary to go to Settings – Apps – My App – Permission.
Access to Storage is probably disabled. Tap Storage to enable it:
With enabled Storage option, the application was able to read the file.
To solve this problem in a proper way, it’s necessary to add a request for permission to the code. Here is a sample in Kotlin:
You can find more details about requesting permissions in Android documentation.