I've been struggling for a couple of days with trying to save and retrieve a map file. The map contains a few string values and a list. The problem is that if the list is being saved, and I don't know if that is true, I can't retrieve it. Here's a piece of test code:
I've tried a number of variations with no success.
Can anyone help me on this?
B4X:
Sub Test_Click
'' Test for saving and retrieving a map
Dim lst1, lst2 As List
Dim map1 As Map
lst1.Initialize
lst1.Add("Number1")
lst1.Add("Number2")
lst1.Add("Number3")
map1.Initialize
map1.Put("Text1","Text 1")
map1.Put("Text2","Text 2")
map1.Put("List",lst1)
map1.Put("Text3","Text 3")
lst2 = map1.Get("List")
Log(map1.Get("Text1"))
Log(map1.Get("Text2"))
Log(map1.Get("Text3"))
For i = 0 To lst2.Size - 1
Log(lst2.Get(i))
Next
' Now save the map to a file
File.WriteMap("/mnt/sdcard/mme/data", "TestFile", map1)
' Empty the lists and map
map1.Clear
lst1.Clear
lst2.Clear
' And read the map back
map1 = File.ReadMap("/mnt/sdcard/mme/data", "TestFile")
' And read the results
Log(map1.Get("Text1"))
Log(map1.Get("Text2"))
Log(map1.Get("Text3"))
' We're good so far - but the program halts on this line (with no info from the debugger):
lst2 = map1.Get("List")
For i = 0 To lst2.Size - 1
Log("Read back" & lst2.Get(i))
Next
End Sub
Can anyone help me on this?