Android Question Filedialog shows no folders and/or files on some devices (android 10)

mc73

Well-Known Member
Licensed User
Longtime User
After my last app update, targeting SDK 29, I receive some emails by users, with screenshots showing that no directories and/or files are shown while opening fileDialog with path set to dirRootExternal. These users insist that there was no problem in the previous app version.
Unfortunately I cannot replicate this, and to be honest, I'm not even sure that changing the target SDK made a difference, since on my personal phone with android 11, and others with android 10 and 9, there is no problem at all.

Here's my code, first I get permissions:

B4X:
rp.CheckAndRequest(rp.PERMISSION_READ_EXTERNAL_STORAGE)
    wait for activity_PermissionResult (Permission As String, Result As Boolean)
    If Result Then 
        openFileBrowser
    end if

And then opening the fileDialog:
B4X:
Private sd As FileDialog
    sd.FilePath=File.DirRootExternal
    sd.TextColor=Colors.Black 
    sd.FileFilter=".myFileExtension"
    Private sf As Object=sd.ShowAsync("Choose file","OK","Cancel","",Null,False)
    wait for (sf) dialog_result (rt As Int)
    If rt=DialogResponse.POSITIVE Then 
    end if

Wonder if anyone else noted such behavior and if there's a straight forward solution to this which I missed reading about.

(Note: I am aware of the contentChooser lib, still I'm not quite sure if I can really set the filter to my app's file extension format, but in the end if I have to use this, I will open another thread with my specific question.)
 

JohnC

Expert
Licensed User
Longtime User
Did you try adding this to the manifest:
B4X:
SetApplicationAttribute(android:requestLegacyExternalStorage, true)
As suggested with SDK 29 in this post:
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Did you try adding this to the manifest:
B4X:
SetApplicationAttribute(android:requestLegacyExternalStorage, true)
As suggested with SDK 29 in this post:

Thank you very much, I will surely do that!
However, just wondering, in most of devices there is no problem at all.
 
Upvote 0
Top