I am currently doing an Android security application and I'm trying to uncheck a CheckboxPreference
after certain conditions have been made. So I'm trying to uncheck the checkbox by doing this, by default the CheckBoxPreference
is actually false
so it is unchecked.
Preferences:
<CheckBoxPreference
android:id="@+id/isPhysicalTheftEnabled"
android:key="isPhysicalTheftEnabled"
android:title="Enable Physical Theft Protection"
android:summary="Select to enable the Physical Theft Protection"
android:defaultValue="false"/>
<Preference android:key="physicaltheft" android:title="Set Physical Theft Protection Password" android:dependency="isPhysicalTheftEnabled"></Preference>
SharedPreferences
inside Activity
:
SharedPreferences sp = getSharedPreferences("isPhysicalTheftEnabled", MODE_WORLD_READABLE);
SharedPreferences.Editor ed = sp.edit();
ed.putBoolean("isPhysicalTheftEnabled", false);
ed.commit();
The CheckBoxPreference
wouldn't be untick even if I have done so. Any idea what could be the problem?