Try this code of snippet.. It works perfect...
OnCreate Method code :
pref = getSharedPreferences(Constants.PREF_SETTINGS, 0);
rg_numberOfQuestions = (RadioGroup) findViewById(R.id.radioGroup1);
rb_1 = (RadioButton) findViewById(R.id.radioOne);
rb_1.setOnCheckedChangeListener(this);
rb_2 = (RadioButton) findViewById(R.id.radioTwo);
rb_2.setOnCheckedChangeListener(this);
rb_3 = (RadioButton) findViewById(R.id.radioThree);
rb_3.setOnCheckedChangeListener(this);
int selected_radio_button = pref.getInt("radio", 0);
if(selected_radio_button!=0)
{
RadioButton button = (RadioButton) findViewById(selected_radio_button);
button.setChecked(true);
}
And the listener code :
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked)
{
Editor editor = pref.edit();
editor.putInt("radio", buttonView.getId());
editor.commit();
}
}