You want to implement on check chnge listener in your class when the check box is check Add the value in string or any where you desire on uncheck simply remove that And when you come back to your view You want to check first the value if match then check the check box of that location This may helps you
OnCheckedChangeListener Check_Boxes_Listener = new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
CheckBox cb = (CheckBox) buttonView;
if (cb.isChecked() == true) {
if (Maximum_Selected_Check_Boxes < 16) {
Maximum_Selected_Check_Boxes++;
HashMap<String, String> Index = new HashMap<String, String>();
Index.put("Index", cb.getTag().toString());
selectCBs.add(Index);
}
else
if (Maximum_Selected_Check_Boxes >= 16) {
Toast.makeText(Check_Boxes,
"You have selected the Maximum Items",
Toast.LENGTH_SHORT).show();
cb.setChecked(false);
}
} else if (cb.isChecked() == false) {
Maximum_Selected_Check_Boxes--;
String Uncheck = cb.getTag().toString();
int j = 0;
for (int i = 0; i < selectCBs.size(); i++) {
if (Uncheck.equalsIgnoreCase(selectCBs.get(i).get("Index")
.toString())) {
j = i;
selectCBs.remove(j);
try {
Array_of_Update_Query.remove(j);
} catch (IndexOutOfBoundsException e) {
}
}
}
}
}
};
check.setOnCheckedChangeListener(Check_Boxes_Listener);
here is a sample on the method that is used in my running project may be its help you