Checkbox Help

  • Replies:3
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Sep 21, 2012 10:35:55 AM via Website

I need help with saving the state of a Checkbox.

I want to select a checkbox, then close the app and when i open the app again, i want the checkbox to still be selected.

Please can somebody help with this or at least point me in the right direction.
  • Forum posts: 21

Dec 27, 2012 7:36:43 PM via Website

Your save the value in the persistent preferences when clicked. And you read its value when populating from layout

SharedPreferences settings = getSharedPreferences("preferences", 0);
final CheckBox checkBox = (CheckBox)findViewById(;
checkBox.setChecked(settings.getBoolean("checkBoxValue", false));
checkBox.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
SharedPreferences settings = getSharedPreferences("preferences", 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("checkBoxValue", checkBox.isChecked());
  • Forum posts: 4

Jan 6, 2013 8:41:46 AM via Website

Read more preferrence in android here
  • Forum posts: 208

Feb 4, 2013 12:37:21 PM via Website

Shared preference is like a database to store the preferences. Go through the tutorial.

if any problem send the code.