title: When to save data to database, onPause() or onStop()?
body: <p>I know this question has been asked a million times, I myself though that I already knew the answer and that the correct one was that the only guaranteed call is to onPause(), so you should save your data there.</p>
  
  <p>However, in many places of android documentation they always suggest not doing heavy work (such as writing data in database) in the onPause() method as it will delay the transition between the activities.</p>
  
  <p>According to <a href="http://developer.android.com/guide/components/activities.html">Android Developer Guide in Table 1</a></p>
  
  <blockquote>
    <p>onPause(): This method is typically used to commit unsaved changes to persistent data, stop animations and other things that may be consuming CPU, and so on. It should do whatever it does very quickly, because the next activity will not be resumed until it returns.</p>
    
    <p>Killable: YES</p>
  </blockquote>
  
  <p>Then according to <a href="http://developer.android.com/reference/android/app/Activity.html">Android Developer Reference Guide in the similar table</a>.</p>
  
  <p>It says the same thing but:</p>
  
  <blockquote>
    <p>Killable: Pre-HONEYCOMB</p>
  </blockquote>
  
  <p>And they add a little note that says:</p>
  
  <blockquote>
    <p>Be aware that these semantics will change slightly between applications targeting platforms starting with HONEYCOMB vs. those targeting prior platforms. <strong>Starting with Honeycomb, an application is not in the killable state until its onStop() has returned</strong>. This impacts when onSaveInstanceState(Bundle) may be called (it may be safely called after onPause() and allows and application to safely wait until onStop() to save persistent state.</p>
  </blockquote>
  
  <hr>
  
  <p>Killable</p>
  
  <blockquote>
    <p>Note the "Killable" column in the above table -- for those methods that are marked as being killable, <strong>after</strong> that method returns the process hosting the activity may killed by the system at any time without another line of its code being executed.</p>
  </blockquote>
  
  <p><strong>FOR POST-HONEYCOMB (i dont care about earlier versions):</strong>
  So, is it OK to assume that any Android device (including different ROMS) will ensure a call to onStop on the activity? And this is the best place to make any time consuming storage writing of the App?</p>
  
  <p><em>Note: This is extremely confusing as most answers here, sites, books, and even online android tests take as a correct answer that you should save it in onPause and NOT in onStop.</em></p>