Skip to content

Instantly share code, notes, and snippets.

@noaht11
Last active August 29, 2015 14:27
Show Gist options
  • Save noaht11/036c6462ffad6aac005f to your computer and use it in GitHub Desktop.
Save noaht11/036c6462ffad6aac005f to your computer and use it in GitHub Desktop.
How to save very simple state
private static final String STATE_COUNTER = "counter";
private int mCounter;
...
@Override
protected void onSaveInstanceState(Bundle outState) {
// Make sure to call the super method so that the states of our views are saved
super.onSaveInstanceState(outState);
// Save our own state now
outState.putInt(STATE_COUNTER, mCounter);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment