Writing Map Contents to File

mangojack

Expert
Licensed User
Longtime User
I was looking to the Map object to save app settings (4 settings)

Just wish to confirm that if I initially write say 3 settings to file,
B4X:
m.Put("Key1", "Aaa") 
m.Put("Key2","Bbb")
m.Put("Key3", "Ccc")      
File.WriteMap(File.DirDefaultExternal, "settings.txt", m)

and later write a 4th key by itself .. ie

B4X:
m.Put("Key4", "Ddd")   
File.WriteMap(File.DirDefaultExternal, "settings.txt", m)

I have in fact overwritten the first three keys , and that all WriteMap methods would have to be for the entire key / value set

Many thanks
Cheers mj
 

Theera

Well-Known Member
Licensed User
Longtime User
Hi mangojack,
I think that your project could use Erel's KeyValueStore,Right?
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Thanks Theera .. yes I was looking at KeyValueStore . Although the app settings would be rarely changed (db create and delete) a map might be sufficient for now, but in the future maybe more settings and using a Map might become a problem.

Cheers mj
 
Upvote 0
Top