I have a map object and want the value of the key to be another map... Do this all the time... no biggie..
But, I want to store this map in a SQLite table field (of type - TEXT), and later send record to my server and insert into MySQL table feild.
I think I understand it must be serialized to accomplish the feat.
I have studied Erels "new" KeyValueStore to try and learn how.
Questions:
Does one serialize each value - or does one serialize the entire map? (containing the value map with strings for their values) - very small in size....
Also, does the table field type for value have to be NONE, as with the CreateTable method in his example?
But, I want to store this map in a SQLite table field (of type - TEXT), and later send record to my server and insert into MySQL table feild.
I think I understand it must be serialized to accomplish the feat.
I have studied Erels "new" KeyValueStore to try and learn how.
Questions:
Does one serialize each value - or does one serialize the entire map? (containing the value map with strings for their values) - very small in size....
Also, does the table field type for value have to be NONE, as with the CreateTable method in his example?
B4X:
Sub GetStopVeh() As ResumableSub
Dim m, v As Map
m.Initialize
v.Initialize
v.Put("etcon",etcon.Text)
v.Put("etfreight",etfreight.Text)
v.Put("etfuel",etfuel.Text)
v.Put("etlight",etlight.Text)
v.Put("etsurface",etsurface.Text)
' other side
v.Put("etothcon",etothcon.Text)
v.Put("etothfreight",etothfreight.Text)
v.Put("etothfuel",etothfuel.Text)
v.Put("etothlight",etothlight.Text)
v.Put("etothsurface",etothsurface.Text)
Log("What key size: "&v.Size)
For Each key As String In v.Keys
Log("What key: "&key)
Dim myser As B4XSerializator
myser.ConvertObjectToBytes( v.Get(key) ) ' ????
' this waited forever - no looping
' Wait For (myser) myser_ObjectToBytes (Success As Boolean, Bytes() As Byte)
' If Success Then
' sql1.AddNonQueryToBatch("INSERT OR REPLACE INTO main VALUES(?, ?)", Array(key, Bytes))
' Log("Each serialize object: " & v.Get(key))
' Else
' Log("Failed to serialize object: " & v.Get(key))
' End If
Sleep(100)
Next
m.Put("stopveh",v) '???
Return m
End Sub
B4X: