After put date getSharedPreferences, You have to initialize your checkboz state with this data in onCreate, like below
// onCreate
SharedPreferences settings = getSharedPreferences("syllabus", 0);
Boolean isChecked = settings.getBoolean("cbx1_ischecked", false);
checkbox1.setChecked(isChecked );
manpreet
Best Answer
2 years ago
In my app ,one interface has some checkBoxes,I wish after I exit the interface, the CheckBoxes should maintain the state.So next time I enter it can show what I have done last time.I have used
SharedPreferrences
to achieve this.But it doesn't work. when I return to this page, All checkBox show state that "every item is unselected ".
How can I realize the function I wish?