I am trying to write a single txt file with the values from 2 map views.
Here is the code I have used:
B4X:
Dim map1 As Map
Dim map2 As Map
map1.Initialize
map2.Initialize
map1.Put("Key1","Value1")
map1.Put("Key2","Value2")
map1.Put("Key3","Value3")
map2.Put("K1","MyValue1")
map2.Put("K2","MyValue2")
map2.Put("K3","MyValue3")
File.WriteMap(File.DirRootExternal , "MyMap.txt", map1)
The above works when writing map1 but can't work out how to also save map2 into the same txt file.
Anyone know how to save map1 and then add map2 at the end of the txt file ?
I ended up converting both maps into a List and then saving the List:
B4X:
Dim map1 As Map
Dim map2 As Map
map1.Initialize
map2.Initialize
map1.Put("Key1","Value1")
map1.Put("Key2","Value2")
map1.Put("Key3","Value3")
map2.Put("K1","MyValue1")
map2.Put("K2","MyValue2")
map2.Put("K3","MyValue3")
Dim List1 As List
List1.Initialize
For i = 0 To Map1.Size - 1
List1.Add(Map1.GetValueAt(i))
Next
For i = 0 To Map2.Size - 1
List1.Add(Map2.GetValueAt(i))
Next
File.Writelist(File.DirRootExternal , "MyMap.txt", List1)
Its risky business to store complex structures in files using WriteList WriteMap or those functions. I've been bitten more than once trying to do that and many times a list or map will be converted to a string.