SharedPreferences & boolean

后端 未结 3 1876
不知归路
不知归路 2021-01-07 11:26

I\'m trying to set the \"isPhysicalTheftEnabled\" to false when a method is executed, but this doesn\'t seem to work. Anyone have any idea?

        SharedPre         


        
3条回答
  •  孤街浪徒
    2021-01-07 11:57

    You need to call editorObject.commit(); after you done with putting data into SP.

    For your problem replace your code with below code...

            SharedPreferences sp = getSharedPreferences("isPhysicalTheftEnabled", MODE_WORLD_READABLE);
            SharedPreferences.Editor ed = sp.edit();
            ed.putBoolean("isPhysicalTheftEnabled", false);
            ed.commit();
    

提交回复
热议问题