title: Keeping object's state when user presses "Back" button
body: <p>I have an app in which I programmatically create an <code>EditText</code> view. I assign an ID to that view using <code>setId()</code></p>
  
  <pre><code>myEditText.setId(100);
  </code></pre>
  
  <p>so that Android automatically saves that object's state when pausing/stopping the app (as I was advised to do <a href="https://stackoverflow.com/questions/19234653/edittext-not-automatically-saved-on-screen-orientation-change">here</a>). It <strong>works</strong> in these cases:</p>
  
  <ul>
  <li>(1) When I leave the app using the "Home" button: if I then come back to the app, the object's state (displayed text) is restored, as expected.</li>
  <li>(2) On a screen orientation change (which involves Android automatically destroying the activity and restoring it through a <code>Bundle</code>). The object state is also kept.</li>
  </ul>
  
  <p>However, it <strong>doesn't work</strong> in this case:</p>
  
  <ul>
  <li>(3) When I leave the app using the "Back" button: if I then come back to the app, the <code>EditText</code> object is empty.</li>
  </ul>
  
  <p>Any explanation as to why this happens? Does Android really distinguish between leaving the app with "Home" and with "Back"? According to the <a href="http://developer.android.com/training/basics/activity-lifecycle/recreating.html" rel="nofollow noreferrer">documentation</a>, the object's state should be automatically preserved, through a <code>Bundle</code>, <em>even when the activity is destroyed</em>. And that clearly happens in case (2). But not in case (3)!</p>
  
  <p>If this is normal behaviour, how could I have the app's state automatically saved and restored when the user presses "Back"? I know I could use the SharedPreferences for that, but I'd rather have Android do that automatically, just as it does in cases (1) and (2).</p>
  
  <p>This happens at least in Android 4.0 and 4.2 (I haven't tested others).</p>