Android Question [solved]why read assets' files error?

Maodge

Member
Licensed User
Hi,
I have some questions about read asset files.
in this method
B4X:
mystring = File.ReadString(File.DirAssets,"0123.txt")
    Log("1 read 0123.txt : " & mystring)
i can get the correct strings.

but when i chose this file through fileexplorer.
it returns error strings.
B4X:
    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_EXTERNAL_STORAGE)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result = False Then
        ToastMessageShow("No permission...", True)
    Else
        dlgFileExpl.Initialize(Activity,"/mnt","",True,False,"OK")
        dlgFileExpl.Explorer
        If Not(dlgFileExpl.Selection.Canceled Or dlgFileExpl.Selection.ChosenFile = "") Then
            MsgboxAsync( "File:" & dlgFileExpl.Selection.ChosenFile & CRLF & dlgFileExpl.Selection.ChosenPath, _
        "you choice")
            Log ("File:" & dlgFileExpl.Selection.ChosenFile & CRLF & dlgFileExpl.Selection.ChosenPath)
            Starter.mystring = File.ReadString(dlgFileExpl.Selection.ChosenPath,dlgFileExpl.Selection.ChosenFile)
            Log ("read strings : " & Starter.mystring)
        End If
    End If
thanks

Log here:
*** Service (starter) Create ***
1 read 0123.txt path : AssetsDir
1 read 0123.txt : 0123456789
abcdefghij
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
File:0123.txt
/mnt/sdcard/Android/data/b4a.example/files/virtual_assets
read strings : ���������������30426153����JLJNIMK�����W���������
 

Attachments

  • test_assets.zip
    25.4 KB · Views: 323
Top