I've seen in some places that it is okay (or even advisable) to persist data in the onPause() method.
Like here
https://stackoverflow.com/a/41778266/3913107
and here
https://stackoverflow.com/a/29496430/3913107
However, the documentation states:
onPause() execution is very brief, and does not necessarily afford enough time to perform save operations. For this reason, you should not use onPause() to save application or user data, make network calls, or execute database transactions; such work may not complete before the method completes. Instead, you should perform heavy-load shutdown operations during onStop()
https://developer.android.com/guide/components/activities/activity-lifecycle#onpause
What am I missing?
So that documentation is a little dated. For example it says not to do networking in onPause- you can't anyway. Networking needs to be on a thread other than the main thread, and onPause is always called on the main thread. You could send off a request to another thread to do networking, but that isn't a problem no matter where you do it.
The tradeoffs between doing it in onPause and onStart is when its called. onPause is called when the Activity is no longer foreground. onStop is called when the activity is totally off screen. So onPause will be called in a few situations without calling onStop. This makes me prefer onPause.
The real lesson is that both onPause and onStop should be fast. Don't do a lot of work in either. If you need to do something that isn't quick, do it on another thread. Of course that goes for pretty much everything on the main thread- if it isn't quick, do it somewhere else.