Android Question How to get the map in the map ?

fash866

Member
Licensed User
please see my code:
B4X:
    Dim test As Map
    test.Initialize
    test.Put("a","abc")
    test.Put("b","234")
   
    Dim test2 As Map
    test2.Initialize
    test2.put("a1","111")
    test2.put("a2","222")
   
    test.Put("c",test2)
   
    File.WriteMap(File.DirInternal,"tttt",test)
   
    Dim ok As Map
    ok.Initialize
    ok=File.ReadMap(File.DirInternal,"tttt")

    Dim ok2 As Map
    ok2 = ok.Get("c") ' Here is the wrong code, How to get the "test2"
 

DonManfred

Expert
Licensed User
Did you get any error message? WHAT ERROR MESSAGE?????

To save a map in a map you need to write and read a OBJECT
Writemap does only work on primitives int, long, real, string

Use Keyvaluestore and write (and reread) the map with
B4X:
' write the map
kvs.PutObject("map",m)

' read the map
dim m as map =  kvs.GetObject("map")
 
Last edited:

fash866

Member
Licensed User
Did you get any error message? WHAT ERROR MESSAGE?????

To save a map in a map you need to write and read a OBJECT
Writemap does only work on primitives int, long, real, string

Use Keyvaluestore and write (and reread) the map with
B4X:
' write the map
kvs.PutObject("map",m)

' read the map
dim m as map =  kvs.GetObject("map")
You are not initializing the "ok2" map.
 

Attachments

Top