hedzr / android-file-chooser

a lightweight file/folder chooser or picker
Apache License 2.0
284 stars 62 forks source link

Its not displaying the files/folders for Android 10 #88

Closed MFR1 closed 4 years ago

MFR1 commented 4 years ago

Hi There,

I have implemented the file chooser correctly to my Android Project, it's working great for Android 5 and Android 7 but for Android 10, it's not showing the files and folders correctly.

Guiorgy commented 4 years ago

@MFR1 On Android Q you can request requestLegacyExternalStorage, however, beginning from Android R (11) google is deprecating the Java File api which this library uses in favor of their SAF (which is slower but technically more secure). More info here

MFR1 commented 4 years ago

Hi, @Guiorgy Thanks for the details. I have already applied android:requestLegacyExternalStorage="true" in application tag in the manifest.xml file and it worked after that. Just a question, what would happen in the case of Android R(11)? Do we have to update something to make it work in that version or we should wait for an update of this repository?

Guiorgy commented 4 years ago

@MFR1, in short, the File api will only work inside your app folder in Android data, and will only be accessible by your app (not counting rooted phones). Anywhere else you will have to use google's SAF or Mediastore api which uses URI instead of Files and completely relies on the provider present on the phone. Even Read/Write external permission in manifest will be deprecated and ignored!

So basically, none of the current chooser libraries will work. You either have to have separate code for pre 11 and post, or completely migrate. (I personally completely moved my app to SAF for example). One reason why so many people hate what google has done...

MFR1 commented 4 years ago

@Guiorgy Thanks for the explanation, I have got the idea. It sounds like we will not be able to use the local file storage in our apps on Android 11.