Android Question FileDialog lists Folders but not Files

lip

Active Member
Licensed User
Longtime User
After a recent update (targetSdkVersion="33" from "31") some newer tablets (eg Android version 13) are listing sub-directory names but not the files within a folder. Older tablets (Android version 10) seem to be OK. The permission bit and the folder name are working fine, as evidenced by the sub-directory folder names being visible and correct. I do not have any filter on the file names.

My code includes:
FileDialog:
    Dim fd As FileDialog
        fd.FastScroll = True

    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    Log("Result after Wait (" & Permission & " = " & Result)
    If Result Then
        Starter.ExternalStorageAllowed = True
    Else
        Starter.ExternalStorageAllowed = False
    End If
    
    If Starter.ExternalStorageAllowed Then
        If File.IsDirectory(File.DirRootExternal, "Download") Then
            fd.FilePath = File.DirRootExternal & "/Download/"
            Log("1 fd = " & fd.FilePath)
        Else
            fd.FilePath = Starter.PathDrawings 'Change to Downloads
            Log("2 fd = " & fd.FilePath)
        End If
    Else
        fd.FilePath = Starter.PathDrawings
        Log("3 fd = " & fd.FilePath)
    End If
            
    Dim ret As Int
        ret = fd.Show("Choose a file to load:", "Okay", "Cancel", "", Null)
 

DonManfred

Expert
Licensed User
Longtime User
File.DirRootExternal
whenever you see this you immediatly know it is broken.

You do not have access to this path.
See
 
Upvote 1

lip

Active Member
Licensed User
Longtime User
whenever you see this you immediatly know it is broken.

You do not have access to this path.
See
I can use GetSafeDirDefaultExternal to get to the Apps folder, and I can browse to get to the Download folder, but this still only shows Sub-Directories and no files. I am trying to let the user browse to the Downloads folder to import a file. Is this no longer possible?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User

Access to directories​

You can no longer use the ACTION_OPEN_DOCUMENT_TREE intent action to request access to the following directories:


  • The root directory of the internal storage volume.
  • The root directory of each SD card volume that the device manufacturer considers to be reliable, regardless of whether the card is emulated or removable. A reliable volume is one that an app can successfully access most of the time.
  • The Download directory.

If you app is supposed to be on playstore then you do not have access anylonger.
If not then you can use targetsdk 28 and have access to it.
 
Upvote 0

lip

Active Member
Licensed User
Longtime User
If you app is supposed to be on playstore then you do not have access anylonger.
If not then you can use targetsdk 28 and have access to it.
Understood. Doomed then. I guess the work around is that I can tell users to download emailed files to another folder (say the "Pictures" folder) then I can give the App access to Pictures?
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
There is a way around it, but I've yet to learn how to impliment it.

For example, my phone is running the latest AOSP Android 14, and Discord has a way to attach and save files. I have noticed though that when you go and select a file like from Downloads to attach into Discord, it uses the android built-in file manager that's in system, and not anything that is built into the application.

Perhaps that's the difference. Android itself has to show you and brows the files, and it then passes over a URI or something in which your app can use to go pull the file directly. That is just a guess, however. That is for attaching a file.

Downloading a file from Discord app, it goes directly into the downloads folder. it has a way to access that. One stark difference though is the older apps would ask you where you want to put the file, the newer versions just put it only in Downloads without any user intervention outside of the usual first-time runtime permission request.

If you took pictures from within the Discord app, it used to go into your gallery/DCIM folder. that changed with newer versions, only putting them within the Discord's private external storage directory. Likely to do with these storage changes.
 
Last edited:
Upvote 0
Top