Android Question ReadList - not possible with variable names?

Quillok

Member
Licensed User
Longtime User
Hey,

i'm totally frustrated, sitting since 2 hours in front of a problem and don't get to the point why it isn't working, mybe somebody of you can explain :/

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
Dim HList As List
    HList = File.ReadList(File.DirAssets,"daten/main")

'    HList:    data_1
'            data2

If File.Exists(File.DirAssets,"daten/data_1") Then Msgbox("1","")

Dim HString As String
    HString = HList.Get(0) 'data_1
If File.Exists(File.DirAssets,"daten/"&HString) Then Msgbox("2","")

If File.Exists(File.DirAssets,"daten/"&HList.Get(0)) Then Msgbox("3","")

End Sub

I only get the first messagebox.
Why isn't it possible to open a list with the other two lines?

I'm very tired, maybe thats the problem, but I've read it, deleted it, wrote it again... and nothing changes in my head and on the error -.-

Help please
 

DonManfred

Expert
Licensed User
Longtime User
File.Exists does not work with DirAssets. Copy the file to DirInternal or any other path and use it here.
 
Upvote 0

Quillok

Member
Licensed User
Longtime User
Thank you for your replies.

But this is a sample of my problem. When I try to load the lists into a list with file.Readlist I've got the same problem.
The first one is loaded, the second and third not, here I've got an error that the file can not be found :/
 
Upvote 0

Quillok

Member
Licensed User
Longtime User
The internal folder is missing. You will need to add it yourself to the zip folder.

I've packed the whole project folder now and did not export it as zip... i did not know what you meant with internal folder because there is no folder with this name.
 

Attachments

  • readlisttest.zip
    34.3 KB · Views: 174
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Step #1:
B4A_QZ2pHsrQjG.png


Step #2: open the file with Notepad++ and see that it is encoded with UTF8 BOM:
5ZWtdFwanR.png


Option 1: convert the file to UTF8 with Notepad++.
Option 2:
B4X:
Dim tr As TextReader
tr.Initialize(File.OpenInput(File.DirAssets,"daten/main")) 'ignore
tr.Skip(1) 'skip over the BOM mark.
Dim list As List = tr.ReadList
Dim HString As String = list.Get(0)
Dim HList3 As List = File.ReadList(File.DirAssets,"daten/" & HString)
 
Upvote 0
Top