Can I have a Map of Maps?

FrankR

Member
Licensed User
Longtime User
Can I do multiple levels of Maps? In other words, can an element of a map contain - another map?

If I can do this for two levels, would that also work with WriteMap and ReadMap?
 

FrankR

Member
Licensed User
Longtime User
I have been able to Load a Map of Maps, and Save it to a file.
I can see it in the file.
When I read the file back and try to access the map of a map with something like

MeterDetailsMap = MeterListMap.Get("ParticularKey")

I get a

java.lang.ClassCastException: java.lang.String

Really stuck.
 
Upvote 0

kickaha

Well-Known Member
Licensed User
Longtime User
I have been able to Load a Map of Maps, and Save it to a file.
I can see it in the file.
When I read the file back and try to access the map of a map with something like

MeterDetailsMap = MeterListMap.Get("ParticularKey")

I get a

java.lang.ClassCastException: java.lang.String

Really stuck.

B4X:
 [From Erels post]WriteMap will convert the inner maps to strings. 
Then when you load the file it will be a map of strings.

So when you do MeterListMap.Get("ParticularKey") it will return a string not a map.
 
Upvote 0

FrankR

Member
Licensed User
Longtime User
Yeah - he did say that, didn't he. :) Thanks for pointing that out. I appreciate it.

I guess I was expecting a method to split that string into another map.

I guess I have to go rework all of this ...
 
Upvote 0
Top