Android Question Writelist with array of list

coslad

Well-Known Member
Licensed User
Longtime User
Hi

i can't understand .
I have:

Dim prova(10) as list

..
if i try to save one list at time :

file.writelist(folder,file.txt,prova(0)) >>>>>> Doesn't works

If i save all the lists :

file.writelist(folder,file.txt,prova) >>>>>> works !!

but when i read back with :

prova=file.readlist(folder,file.txt)

the compiler goes in error (inconvertible types) !!

any idea ?

Thanks
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
    ' DIM lists
    Dim prova(10) As List   
    For i = 0 To 9
        ' Initialize list i
        prova(i).Initialize
        ' Add items to list i
        For o = 0 To 2
            Dim val As Int = ((i+1)*1000)+o
            prova(i).Add("Listitem "&val)
        Next
    Next
    ' Write all lists to a file
    Dim rf As RandomAccessFile
    rf.Initialize(File.DirInternal,"MyLists.lst",False)
    rf.WriteObject(prova,False,0)
    '
    ' To test the written lists
    ' we create a new List of lists under a new name
    Dim savedprova(10) As List
    ' AND then load the saved lists to this new list of lists
    savedprova = rf.ReadObject(0)
  ' LOG all Listentries from all saved lists
    Log("Showing saved Lists including items")
    For i = 0 To 9
        ' Initialize list i
        Dim lst As List = savedprova(i)
        ' Read items from list i
        For o = 0 To lst.Size-1
            Log("List("&i&"): = "&lst.Get(o) )
        Next
    Next
 
Upvote 0
Top