Android Question The path to the file when using the soft emulator

Valeriy Lakhtin

Member
Licensed User
During initialization drawing or reading a text file on the emulator, I have problems. I suspect that when debugging and testing on an soft emulator, the standard DIR File.DirAssets or File.DirInternal - give errors. So I think in the code is necessary temporarily to print a different path. If I'm right do you can tell me how to describe the standard path to the files when use on the emulator. For me to use the emulator is very convenient so do not need me to discourage use of the emulator :)
 

Valeriy Lakhtin

Member
Licensed User
B4X:
Log(File.DirInternal & " DIR")
bitMap.Initialize(File.DirAssets, strIMG)
Eerror rows in log window

/data/user/0/b4a.example/files DIR
java.io.FileNotFoundException: /storage/emulated/0/Android/data/b4a.example/files/virtual_assets/
img_sushi_mal1.png
(No such file or directory)

I checked the file exists in the source directory
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
remove the space from the " DIR"
 
Upvote 0

Valeriy Lakhtin

Member
Licensed User
DIR not impotent word becouse it is in Log string. I have two parts DirAssets and Imge file nam, togethe they have errors. But example with listview with picture work OK. May be a problem in the file extension from my PNG, or in the size of pictures 150x200
 
Last edited:
Upvote 0

Valeriy Lakhtin

Member
Licensed User
I want to get a listView with a picture using data from XML file. I decided to problems with reading XML file. I checked the file name from XML file and checkit it with list files. But I can not activate the image before it is inserted into the list. Maybe me need to copy a picture in other catalog before building the listview. I write my code as Example
B4X:
Sub xomBuilder1_BuildDone(xomDoc As XOMDocument, Tag As Object)
'   Log(LastException.Message)
   If xomDoc.IsInitialized Then
'   If Not (xomDoc=Null) Then   
'         Msgbox(N_Group,"first test")
        Dim RootElem As XOMElement
        RootElem=xomDoc.RootElement
        xomGroups= RootElem.GetChildElementsByName("group")
        N_Group = xomGroups.Size
'       Msgbox(N_Group & "ALL ОК","second test")
        Dim strIMG As String, strName As String, loc_Rating As String, Rating As String, strData As String
        Dim str1 As String, str2 As String
        Dim i As Int
        Dim bitMap As Bitmap

        Log(N_Group)
        For i=0 To N_Group-1
            Try
            ' Задаем рисунок для списка
'            Log(xomGroups.GetElement(i).Value & "Группы")
            xomGroup=xomGroups.GetElement(i)
'            Log(xomGroup.Value & "Группа" )
            xomOption=xomGroup.GetFirstChildElementByName("option")
'            Log(xomOption.Value & "Опции")
            ' Формируем имя группы с рейтингом
            strName=xomGroup.GetFirstChildElementByName("name").Value
            str1=loc_Rating & " " & Rating & " " & strName
            Log(Rating & "Рейтинг")
            strData=xomGroup.GetFirstChildElementByName("time").Value
            str2=strData
            Log(strName & "Имя")
            loc_Rating=xomGroup.GetFirstChildElementByName("loc_rating").Value
            Log(loc_Rating & "Лок рейтинг")
            Rating=xomGroup.GetFirstChildElementByName("rating").Value
           
            strIMG=xomOption.GetFirstChildElementByName("beg_img").Value
            Log(strIMG & "Картинка")
            Log(File.DirAssets & "Каталог")
            bitMap.Initialize(File.DirAssets,  strIMG)
        listView_G.SingleLineLayout.Label.TextSize = 20
        listView_G.SingleLineLayout.Label.TextColor = Colors.Blue
        listView_G.SingleLineLayout.Label.Gravity = Gravity.CENTER
        listView_G.FastScrollEnabled = True
            listView_G.AddTwoLinesAndBitmap(str1, str2, bitMap)  
            Catch 
            Log(LastException.Message)   
            End Try       
            Next
        Else
        Msgbox("Проблемы с файлом","")   
    End If
End Sub
 
Upvote 0

Valeriy Lakhtin

Member
Licensed User
Now I instaled SDK ver 4.2 and 5.1 and created new Emulator. Now my application with new emulator work more beter then SDK ver 6. I testing my application...
 
Last edited:
Upvote 0
Top