I would like to know the best way OR the expected way to update the VALUE of an already existing KEY in KeyValueStore database.
Should I delete the Key and its value first and then Create a new Key and the New Value using kvs.putsimple / kvs.PutEncrypted ?
For eg.
B4X:
If Starter.kvs.ContainsKey("SmtpDetails") Then
Starter.kvs.Remove("SmtpDetails") 'Remove, if, already exists. Then add
Starter.kvs.PutEncrypted("SmtpDetails",Starter.MapSmtpDtls,"MyPassword")
Else
Starter.kvs.PutEncrypted("SmtpDetails",Starter.MapSmtpDtls,"MyPassword")
End If
OR Can I directly update the store without deleting the Key first ? Will this method update the value of the existing key ?
Can I store a Boolean Value in KeyValueStore ?
If yes, then is the following the right way to do it
B4X:
Dim IsAutoLogin as Boolean
IsAutoLogin = True
kvs.PutSimple("AutoLogin",IsAutoLogin)
You can use put for the existing one. It will update the old entry. You dont need to delete and add each time.
I never tried if it stores boolean but it take 2 min to try it. You can try it and see.
I would like to know the best way OR the expected way to update the VALUE of an already existing KEY in KeyValueStore database.
Should I delete the Key and its value first and then Create a new Key and the New Value using kvs.putsimple / kvs.PutEncrypted ?
For eg.
B4X:
If Starter.kvs.ContainsKey("SmtpDetails") Then
Starter.kvs.Remove("SmtpDetails") 'Remove, if, already exists. Then add
Starter.kvs.PutEncrypted("SmtpDetails",Starter.MapSmtpDtls,"MyPassword")
Else
Starter.kvs.PutEncrypted("SmtpDetails",Starter.MapSmtpDtls,"MyPassword")
End If
OR Can I directly update the store without deleting the Key first ? Will this method update the value of the existing key ?
Can I store a Boolean Value in KeyValueStore ?
If yes, then is the following the right way to do it
B4X:
Dim IsAutoLogin as Boolean
IsAutoLogin = True
kvs.PutSimple("AutoLogin",IsAutoLogin)