Android Fragment Save States Of Views

To save the Fragment state in Android you can do this. First save the state:

    public void onSaveInstanceState(Bundle outState) {
        outState.putInt("curChoice", mCurCheckPosition);

And later use it:

    public void onActivityCreated(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
            // Restore last state for checked position.
            mCurCheckPosition = savedInstanceState.getInt("curChoice", 0);
Posted in Android, Tips and Tricks Tagged with: , ,