Files.writelist for Variabel Type problem

BudiWang

Member
Licensed User
Longtime User
Hi

i try this code
B4X:
Sub Process_Globals
      Type ChatLogView (Ctag As String,Cnama As )
End Sub

Sub SaveLog
     dim p as ChatLogView
     dim l as list
     dim x as int

     l.Initialize    
     for x=0 to 5
          p.Ctag=x
          p.Cnama="Person" & x
          l.add(p)
     next
     file.writelist(File.DirDefaultExternal, "test.log",l)
End Sub     

Sub LoadLog
    dim l as list
    dim p as ChatLogView
     l.Initialize    
    l=file.readlist(File.DirDefaultExternal, "test.log")
    p=l.get(0)
end sub

I got error on syntax "p=l.get(0)"

java.lang.ClassCastException: java.lang.String cannot be cast to b4a.example.test$_chatlogview

Need Help :sign0085: :sign0085:
 

BudiWang

Member
Licensed User
Longtime User
i understand that list value store in file become string so we cant load as the variable type anymore. I will learn KeyValueStore class and RandomAccessFile.WriteObject / ReadObject. thanks for your support Erel
 
Upvote 0
Top