I added Button1 to the keyValueStore2 example, it increments the value Starter.pos.
The value persists when opening from 'Recent Apps' but gets re-initialized if the app is closed and re-opened.
I can see that datastore22 is updated each time the app closes.
I even tried a few If/Else statements in Starter_Create but still need a pointer on how to get around the re-initialize issue.
added the project file.
The value persists when opening from 'Recent Apps' but gets re-initialized if the app is closed and re-opened.
I can see that datastore22 is updated each time the app closes.
B4X:
Sub Button1_Click
Starter.pos = Starter.pos + 1
Starter.kvs.Put("numbers", Starter.pos) 'updates Pos, not persistent
Log("Button1_Click update Pos = " & Starter.pos)
End Sub
B4X:
#Region Service Attributes
Sub Process_Globals
Public kvs As KeyValueStore
Dim pos = 4 As Int[\code]
End Sub
Sub Service_Create
kvs.Initialize(File.DirDefaultExternal, "datastore22") '
Log("Service_Create pos= " & (kvs.Get("numbers")))
End Sub
Last edited: