Q:

How to get data from bundle of onSaveInstanceState in Android

Hello I am trying to get the data from bundle of onSaveInstanceState of Activity in Android.
I am looking to get value of this attribute curTab which are in bundle data.
Bundle data is here :
Bundle[{android:viewHierarchyState=Bundle[{android:views={16908290=android.view.AbsSavedState$1@4178b1e8, 16908294=android.view.AbsSavedState$1@4178b1e8, 16908305=android.view.AbsSavedState$1@4178b1e8, 16908306=FragmentTabHost.SavedState{426e3158 curTab=parent2}, 16908307=android.view.AbsSavedState$1@4178b1e8, 16908310=android.view.AbsSavedState$1@4178b1e8, 2131492923=android.view.AbsSavedState$1@4178b1e8, 2131492993=android.view.AbsSavedState$1@4178b1e8, 2131493010=android.view.AbsSavedState$1@4178b1e8, 2131493204=android.view.AbsSavedState$1@4178b1e8, 2131493205=android.view.AbsSavedState$1@4178b1e8, 2131493206=android.view.AbsSavedState$1@4178b1e8, 2131493207=android.view.AbsSavedState$1@4178b1e8, 2131493208=android.view.AbsSavedState$1@4178b1e8, 2131493209=android.view.AbsSavedState$1@4178b1e8, 2131493210=android.widget.ProgressBar$SavedState@426e3140, 2131493211=android.view.AbsSavedState$1@4178b1e8}, android:focusedViewId=2131493221}], android:support:fragments=android.support.v4.app.FragmentManagerState@426e4770}]

I am trying to get curTab like this but I am getting null. 
@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    Log.d("Demo", outState.getString("curTab"));
}

Edit
@Override
public void onDestroy() {
    super.onDestroy();
    Log.d("Demo", "onDestroy");
}

@Override
protected void onSaveInstanceState(Bundle savedInstanceState) {
    super.onSaveInstanceState(savedInstanceState);
    savedInstanceState.putInt("current_tab_selected", mTabHost.getCurrentTab());
}

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
  super.onRestoreInstanceState(savedInstanceState);
  int selectedTab = savedInstanceState.getInt("current_tab_selected");
  Log.d("Demo", selectedTab + "");
}

@Override
public void onCreate(Bundle savedInstanceState) {

    ...

    if(savedInstanceState != null) {
        int selectedTabIndex = savedInstanceState.getInt("current_tab_selected");
        mTabHost.setCurrentTab(selectedTabIndex);
    }
}

Please help and thanks in advance.

A:

You can not get Data in onSaveInstanceState();
you need to use onRestoreInstanceState() instead of onSaveInstanceState();
Like this:
@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {

  super.onRestoreInstanceState(savedInstanceState);
  String str = savedInstanceState.getString("curTab");

}

Or you can also access this in Activity onCreate(), if Bundle object is contains curTab.
 @Override
    public void onCreate(Bundle savedInstanceState) {

      super.onCreate(savedInstanceState);

       if(savedInstanceState != null)
          String str = savedInstanceState.getString("curTab");

    }

