I use following code to change background of my buttons:

```
 case R.id.purple:
          for (Button currentButton : buttons) {
                currentButton.setBackgroundResource(R.drawable.purple);
            }

```

It changes color of all buttons, but whenever i change screen orientation or take activity to bacground or close my app, the backround color reverts to its default value.How can i save this information so that it is not lost and color of buttons remain same as i assigned it. To save integral or string values i am using this code:

```
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
  super.onSaveInstanceState(savedInstanceState);
  savedInstanceState.putString("MyString", inputText.getText().toString());
  // etc.
}

```

But i don't know how to save state of buttons.