database - store multiple radio groups status android -


i working on app have multiple radio groups.
want save checked status , restore on next restart.

so efficient way that?

i think need use sharedpreferences store checked items in radio groups because present unless uninstall app.

to store value's in shared preferences

list<radiogroup> radiogroups; list<string> savedids;  sharedpreferences preferences = preferencemanager.getdefaultsharedpreferences(this); sharedpreferences.editor editor = preferences.edit(); editor.putstring("number of radio groups", radiogroupscount); for(int i=0; i< radiogroupscount; i++){ editor.putstring("radiogroup"+string.valueof(i), radiobuttongroup.getcheckedradiobuttonid();); } editor.commit();(); 

to retrieve values shared preferences:

 sharedpreferences preferences = preferencemanager.getdefaultsharedpreferences(this);  string count = preferences.getstring("number of radio groups", 0); if(count >=0){ for(int i=0; < count; i++){  savedids.add(preferences.getstring("radiogroup"+string.valueof(i),""));   }  } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -