title: How does android retain view state across fragment detach/attach
body: <p>I have a tab host control that is loading tabs using fragments.</p>
  
  <p>Each time a tab is switched it detaches the old fragment and attaches the new fragment.</p>
  
  <p>I noticed that the OnCreateView method is called during this process, and that a lot of my state is getting lost since it recreates the view each time.  However I noticed that some view state such as the value of edit text is being maintained across detach/attach.</p>
  
  <p>I'm wondering how Android is automagically restoring state when the view is being completely destroyed and recreated as a new view.  The value of the Bundle savedInstanceState is always null when I am just switching tabs.  Bundle savedInstanceState only becomes populated when I do something like rotating the screen.</p>
  
  <p>as far as I can tell this restoring of state is taking place just before the fragment onStart method is called.</p>