I have three Radio buttons to specify the gender, Male Female and Others. I save this data into my DB as 1 for Male, 2 for female and three for others based on user selection. This is reflected in the profile page, now when I want to edit the profile I want to auto-populate all the fields of my profile page in an editable manner, the user only changes the fields he wants to. Although I am able to fetch the values of 1,2,3 for gender from my database but I am not able to populate the specified radio button as checked. I tried the following:
String M = (c.getString(c.getColumnIndexOrThrow("Gender")));
RadioGroup rb1 = (RadioGroup)findViewById(R.id.radiogroup1);
if(M.equals(1)){
rb1.check(R.id.radiobutton3);
RadioButton rbu1 =(RadioButton)findViewById(R.id.radiobutton3);
rbu1.setChecked(true);
}
else if(M.equals(2)){
rb1.check(R.id.radiobutton4);
RadioButton rbu2 =(RadioButton)findViewById(R.id.radiobutton4);
rbu2.setChecked(true);
}
else if(M.equals(3)){
rb1.check(R.id.radiobutton5);
RadioButton rbu3 =(RadioButton)findViewById(R.id.radiobutton5);
rbu3.setChecked(true);
}