Android Question contentchooser for .json file

yfleury

Active Member
Licensed User
Longtime User
I have a json file (BornesFontaines.json) in download folder
I use this for take json file for translate json to db.
B4X:
    Dim test As ContentChooser
    test.Initialize("boiteDialog")
    test.Show("text/*","fichiers")
With .json haven't raise event.
I rename file with .txt
B4X:
public Sub boiteDialog_Result (Success As Boolean, Dir As String, FileName As String)
    Log(Success & " - " & Dir & " - " & FileName)
End Sub
and I have this in log
true - ContentDir - content://com.android.providers.downloads.documents/document/msf%3A5646
Waht I am doing wrong?
 

drgottjr

Expert
Licensed User
Longtime User
"application/json"
 
Upvote 1

yfleury

Active Member
Licensed User
Longtime User
Ok I see and can choose the json file.
But the event raise with this in log
B4X:
true - ContentDir - content://com.android.providers.downloads.documents/document/msf%3A5642
I have choose 2 time the json file to raise event
My event sub
B4X:
public Sub boiteDialog_Result (Success As Boolean, Dir As String, FileName As String)
    Log(Success & " - " & Dir & " - " & FileName)
Bornes_fontaines(Dir, FileName)

I use this to open a json file
B4X:
Public Sub Bornes_fontaines(dossier As String, nomfichier As String)
    Dim json As String
    json = File.ReadString(dossier, nomfichier)
    '    Log (json)
    Dim parser As JSONParser
    parser.Initialize(json)
But I have result for json importation data
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
my contentchooser is different from yours. when the result event is fired, i see:
true - ContentDir - content://com.android.externalstorage.documents/document/primary%3ADownload%2Ffleury.json
and i can open the file, no problem.

this is not what you see... your uri is different, although my uri and yours might point to the same place. i'm using sdk30 on android 12
 
Upvote 0

yfleury

Active Member
Licensed User
Longtime User
B4X:
<uses-sdk android:minSdkVersion="18" android:targetSdkVersion="30"/>
 
Upvote 0

yfleury

Active Member
Licensed User
Longtime User
B4X:
public Sub boiteDialog_Result (Success As Boolean, Dir As String, FileName As String)
    Log(Success & " - " & Dir & " - " & FileName)
'Bornes_fontaines(Dir, FileName)
Dim texte As String

texte= File.ReadString(Dir, FileName)
Log(texte)
When I run that, I read the file.
 
Upvote 0
Top