Android Question How to get the map in the map ?

fash866

Member
Licensed User
Longtime 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
Longtime 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:
Upvote 0

fash866

Member
Licensed User
Longtime 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.

%E6%97%A0%E6%A0%87%E9%A2%98-png.33554
 

Attachments

  • 无标题.png
    无标题.png
    183.8 KB · Views: 230
Upvote 0
Top