Android Question File chooser and reader

Hirogens

Active Member
Licensed User
Longtime User
Hi everybody,

Is there a full library or a simple way to select file and read it in B4A ?
I mean, I made my research. I have found the FilePicker library from @DonManfred
https://www.b4x.com/android/forum/threads/filepicker.69161/
Verygood by the way, but had to correct some permission problems in the example due to sdk26.
And for the reading part, there is the File object from Core lib. BUT, here is my code :

B4X:
Sub FilePicker_onSelectedFilePaths(selected() As String)
    Log($"FilePicker_onSelectedFilePaths(${selected.Length})"$)
    For i = 0 To selected.Length -1
        Log($"${selected(i)}"$)
        shared = selected(i)
        ReadStringExample
    Next
    fp.dismiss
End Sub
Sub ReadStringExample
    Msgbox(File.ReadString(File.DirRootExternal, shared), "")  'NOPE :'(
End Sub
The problem is that I have the fullpath of the file in the shared var, something like, "lol/storage/emulated/0/convertcsv.csv"

and I cannot send it directly to the ReadString() method because it needs to be "lol/storage/emulated/0" and "convertcsv.csv". Yes, it's nothing really hard to deal with, but I don't want to cut my string, or split it with the "/" character, and extract the name, or etc...
So is there an existing thing more powerful than this ?
(FileChooser lib exists only in B4J if I'm right :/)
 

ronell

Well-Known Member
Licensed User
i don't know if there is an existing lib for that, why you dont want to cut the fullpath string? it is much more easier if you use that method
 
Upvote 0

Hirogens

Active Member
Licensed User
Longtime User
Hi !
I would have preferred something clean... and more "dynamic", but yeah, i'll finally do it I guess :) Thank you
 
Upvote 0
Top