i have data in database with value from checkbox
i try to set checkbox with value from database, if database not null checkbox checked but if null checkbox not checked..
my code like this:
public void load(){
final Cursor c = helper.getSat(almagId);
c.moveToFirst();
if(c.getString(3) != null){
ch1.isChecked();
}
isi2.setText(c.getString(4));
if(c.getString(4) != null){
ch2.isChecked();
}
isi3.setText(c.getString(5));
if(c.getString(5) != null){
ch3.isChecked();
}
}
but it’s not work..how can i solve this??thank you for feed back 🙂
isChecked()will tell you if theCheckBoxis checked or not; you cannot change the ‘checked’ value with this method.In order to change it, use either
setChecked(boolean)for an explicit value ortoggle()to inverse it.