Android Question Read file from download folder

Douwe Siegersma

Member
Licensed User
Longtime User
Hello,

I want the user to open a file from the download folder. I use the following code

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout1")
    RP.CheckAndRequest(RP.PERMISSION_READ_EXTERNAL_STORAGE)
   
    Shared = File.Combine(File.DirRootExternal, "Download")
    Log(Shared)
End Sub

Private Sub Button2_Click
    Dim HL As List
    HL.Initialize
    HL = File.ListFiles(Shared)
    For i = 0 To HL.Size-1
        ListView1.AddSingleLine(HL.Get(i))
    Next
End Sub
[CODE=b4x]

I added this to the Manifest:
B4X:
AddManifestText(<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
)

The listview shows only folders, no files.
Where do I go wrong?
 

DonManfred

Expert
Licensed User
Longtime User
Where do I go wrong?
Using File.DirRootExternal! You do not have access to this folder.
 
Upvote 0

Douwe Siegersma

Member
Licensed User
Longtime User
I studied the texteditor example. In the download folder I can see the files but they are all grayed out and can not be selected.
 
Last edited:
Upvote 0

Douwe Siegersma

Member
Licensed User
Longtime User
Maybe I fooled around to much with userpermissions.
I'm now using the ExternalStorage library to copy the file the user picks to File.DirInternal.
 
Upvote 0

Douwe Siegersma

Member
Licensed User
Longtime User
I'm testing on an Android 11 tablet and it works fine. But I shall take a look at the TextEditor example again.
Thank you for your support.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…