I have taken over an outdated Android App written in Java
I have progressively upgraded dependencies without issue until I changed the targetSdkVersion from 27 to 30.
This is for a feature that:
- Allows user to pick an from the gallery or capture from camera
- Saves a value to an application folder
- Sends the picture to an API
I know that pre-Android 10, I could add android:requestLegacyExternalStorage="true"
in the Manifest file and it would work, but that feature was from Android 10+.
If I downgrade the targetSdkVersion, it works.
Otherwise it throws the following errors:
E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /storage/emulated/0/xxxxx/1380402_672833029402941_703996746_n.jpg: open failed: EACCES (Permission denied)
I have narrowed it down to a permissions issue, due to scoped storage restrictions
I understand the concept behind it but I cannot get it to work.
What do I need to do to fix this in Java code, as I don't know how to apply the examples in Kotlin for Java?
I have tried following some of the answers from below:
Sample app: https://github.com/tinonetic/android-questions-scoped-storages