SharedPreferences.getBoolean returns true everytime

后端 未结 4 1911
粉色の甜心
粉色の甜心 2020-12-20 16:07

I made a class for handling important data changes such as App Purchase Status and other stuff .

For this goal I have created a class which does the setting and read

4条回答
  •  误落风尘
    2020-12-20 16:49

    Actually there is a problem in your code!! thats why its always showing purchased!!

     if (settings.getBoolean(keyPurchase,true)){
                purchased = true;
            }
    

    in this lines if the keyPurchased tag if not used , u are passing true value by default so when u call

    if (appCore.appIsPurchased()){
    

    it always return a true value.. The solution is that make sure that the preference values are set before u call them.. hope this helps

提交回复
热议问题