HBiSoft / PickiT

An Android library that returns real paths from Uri's

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Android 10 devices getting EACCES (Permission denied)

angelkoh opened this issue · comments

your codes uses getExternalStorageDirectory() which will return an exception when we try to run it on Android 10 devices with targetSdkVersion 29.

file with the deprecated code https://github.com/HBiSoft/PickiT/blob/master/pickit/src/main/java/com/hbisoft/pickit/Utils.java

referring to https://developer.android.com/reference/android/os/Environment#getExternalStorageDirectory()

To improve user privacy, direct access to shared/external storage devices is deprecated. When an app targets Build.VERSION_CODES.Q, the path returned from this method is no longer directly accessible to apps. Apps can continue to access content stored on shared/external storage by migrating to alternatives such as Context#getExternalFilesDir(String), MediaStore, or Intent#ACTION_OPEN_DOCUMENT.

Deprecated doesn't mean we can't use it anymore.

In Android 10 file path access was removed and it was returned in Android 11.
Add android:requestLegacyExternalStorage="true" in your manifest:

<manifest ... >
  <application 
    android:requestLegacyExternalStorage="true" 
  ... >
    ...
  </application>
</manifest>

Please let me know asap, I will implement it into the library after you have confirmed.
I forgot to add this.

Can you please reply.

I updated the readme. No response. Closing.

Yes, on Android 11 it will be ignored, but you still have to keep it in your manifest for it to work on Android 10.

Google confirmed this on an issue I opened - https://issuetracker.google.com/issues/151407044

Like I said in my previous comment, file path access returned in Android 11. android:requestLegacyExternalStorage="true" is only for Android 10.