Android Question keyvaluestore problem

tufanv

Expert
Licensed User
Longtime User
Hello,

I am using subscriptions in my app. I need to store subscription info for some reason so i decided to use keyvaluestore to store some private data. With the launch of the app i need to check a key with kvs with this code:
B4X:
If kvs.GetEncryptedObject("gecerlitarih","password") = "ok"

but at this point, because that there is no subscription purchased by the user, there is no key stored yet as "gecerlitarih" which returns me an error :
B4X:
(NullPointerException) java.lang.NullPointerException

How can i fix this?

ty
 

udg

Expert
Licensed User
Longtime User
Try a key exist test before kvd.Get...:
B4X:
'Tests whether a key is available in the store.
Sub ContainsKey(Key AsString) As Boolean
 
Upvote 0
Top