You could implement this method:
selectSavedRadioButton(RadioGroup group, String savedButtonPreferencesKey) {
RadioButton button = (RadioButton) group.findViewById(getPref(group.getId(), preferencesKey));
if (button != null) {
button.setChecked(true);
}
}
Which you can call like this:
RadioGroup rg_numberOfQuestions = (RadioGroup) findViewById(R.id.radioGroupQuestions);
selectSavedRadioButton(rg_numberOfQuestions, "NQ");