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

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -