What is the correct way to prepare and use KVS?
the concept you are using is a bit incorrect? there is a KVS library somewhere in the forum.
What you are doing is a simple mapping and storing those values on a txt file in a format called java properties (i understand that this looks like a KVS but KVS as a concept is totally different)
your problem is that you are overwritting your map every time.
B4XPages.MainPage.dados = CreateMap( _
CreateMap is creating a whole new map without taking the values of whatever you had before
B4XPages.MainPage.dados = CreateMap( _ "siteno":et_siteno.Text.Trim , _ "gatecode":et_gatecode.Text.Trim)
so when you call this line, you are just overwritting it and all the past references are lost.
instead of creating the map each time with CreateMap, you should use
B4XPages.MainPage.dados.put("key","value")
each time you use put, if the key alerady exists, that value is going ot be overwritten, but JUST for that specific value. not all the others. just be sure that you initialkize it
B4XPages.MainPage.datos.initialize
before starting to use it BUT if you are going to pull it from the file then do not initialize it, just use
B4XPages.MainPage.dados = File.readMap
Should only 1 map be used that contains all fields?
Yes! only one map, but use it correctly