Sub Class_Globals
Private Root As B4XView 'ignore
Type MyPhone(brand As String, mList As List)
End Sub
Public Sub Initialize
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Dim list1 As List
list1.Initialize
For i=1 To 50
list1.add(CreateMyPhone("iphone" & i, Array As Int(100+i,700+2*i)))
Next
'writebytes
Dim ser As B4XSerializator
Dim b() As Byte=ser.ConvertObjectToBytes(list1)
Dim out As OutputStream=File.OpenOutput(File.DirInternal,"1.dat",False)
out.WriteBytes(b,0,b.Length)
out.Close
'Read list:
Dim MyList As List
MyList.Initialize
MyList= ser.ConvertBytesToObject(b)
For i = 0 To MyList.Size - 1
Dim myphone As MyPhone
myphone.Initialize
myphone = MyList.Get(i)
Log($"Brand: ${myphone.brand} Size: ${myphone.mList.Get(0)} ${myphone.mList.Get(1)} "$)
Next
End Sub
Public Sub CreateMyPhone (brand As String, mList As List) As MyPhone
Dim t1 As MyPhone
t1.Initialize
t1.brand = brand
t1.mList = mList
Return t1
End Sub