Android Question saving an array of strings

saunwin

Active Member
Licensed User
Longtime User
Hello,

I seem to be having trouble saving and loading an array of strings. My Log(List1.Size) is equal to 1, which implies the save array hasn't worked. Any advice welcome. TIA



B4X:
Sub mnusavescores_Click
    Dim List1 As List
    List1.Initialize
        Dim arr(12) As String
        arr(0) = TL1.Text
        arr(1) = tl1MSB.Text
        arr(2) = TL1NSB.Text
        arr(3) = TL1LSB.Text
        arr(4) = tl2.Text
        arr(5) = TL2MSB.Text
        arr(6) = TL2NSB.Text
        arr(7) = TL2LSB.Text
        arr(8) = tl3.Text
        arr(9) = TL3MSB.Text
        arr(10) = TL3NSB.Text
        arr(11) = TL3LSB.Text
      
    List1.Add(arr) 'Add the whole array as a single item
    File.WriteList(File.DirRootexternal, "SLR.txt", List1)
End Sub

Sub mnuloadscores_Click
    Dim List1 As List
        List1 = File.ReadList(File.DirRootExternal, "SLR.txt")
  
    Log(List1.Size)
  
    Msgbox("List1.Size = " & List1.Size & CRLF & "The third item is: " & List1.Get(2), "")
  
    TL1.Text=List1.Get(0)
    tl1MSB.Text=List1.Get(1)
    TL1NSB.Text=List1.Get(2)
    TL1LSB.Text=List1.Get(3)
    tl2.Text=List1.Get(4)
    TL2MSB.Text=List1.Get(5)
    TL2NSB.Text=List1.Get(6)
    TL2LSB.Text=List1.Get(7)
    tl3.Text=List1.Get(8)
    TL3MSB.Text=List1.Get(9)
    TL3NSB.Text=List1.Get(10)
    TL3LSB.Text=List1.Get(11)
  
End Sub
 
Top