Hello all
I would like to store some variables in persistent memory with the simplest code to understand and also the shortest possible. I saw kvs2 and I'm looking for an easy to understand example.
Good evening.
I would like to declare, initialize, the kvs2 library to store some variables.
I activated kvs2 and do some tests. But i'm not understand in which sub should we declare kvs2 and initialize it ?
I tried KeyValueStoreExample.zip , after renaming the activity, it compiles but doesn't install.
Is possible to have a simple example without sql ?
Also via this link saves the informations item by item ?
If you want someting that does not use SQL, then using a map is simplest. You can save a map to a file and read the file to retrieve variables.. Here is a full example if the values are strings:
B4X:
Dim a As String ="Paris"
Dim b As String ="London"
Dim c As String ="Athens"
Dim d As String ="Geneva"
Dim m As Map
m.Initialize
m.Put("a", a)
m.Put("b", b)
m.Put("c", c)
m.Put("d", d)
'save map:
File.WriteMap( xui.DefaultFolder, "mycities", m)
'Read the map
Dim mp As Map =File.ReadMap(xui.DefaultFolder, "mycities")
Log(mp.Get("c")) 'returns the value for the key c which is: Athens