SharedPreferences.getBoolean returns true everytime

后端 未结 4 1909
粉色の甜心
粉色の甜心 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:45

    Found It, the problem is that I was thinking

    settings.getBoolean(keyPurchase,false) 
    

    returns the value of keyPurchased variable but the fact is it only returns the variable itself not its value so I fixed the problem by changing the method of my class to this:

    public boolean appIsPurchased(){
        return settings.getBoolean(keyPurchase,false);
    }
    

提交回复
热议问题