Android Question [SOLVED] Problem using File.ListFiles on Download folder - did something change?

Andris

Active Member
Licensed User
Up until recently I've been using File.ListFiles to list the contents of the Download folder and have had no problem. This is basically the code I've used (and yes, the permissions have been granted!):
B4X:
    Dim l As List = File.ListFiles(File.Combine(File.DirRootExternal,"Download"))
    If l.IsInitialized And l.Size > 0 Then
        For i=0 To l.Size-1
            Log(l.Get(i))
        Next
    End If
There are KML and KMZ files in my Download folder, which my app then imports. Now, for a reason I can't figure out, only media files appear (JPG and PNG for example), and the KML/KMZ ones don't get listed! What could be causing File.ListFiles to exclude them?
 

agraham

Expert
Licensed User
You can't do that in API 29. Read this for the workaround or target API 28 when it will still work.

 

Andris

Active Member
Licensed User
You can't do that in API 29. Read this for the workaround or target API 28 when it will still work.

Thanks @agraham. I found this just as you answered!

In summary, for now, add this to manifest editor:
B4X:
SetApplicationAttribute(android:requestLegacyExternalStorage, true)
 
Top