title: Persisting state to files in onPause() takes too long
body: <p>Consider the following situation. I have an application which holds a large amount of data that is persisted into files. I spawn an AsyncTask in the onPause method for this purpose.</p>
  
  <p>The problem is that it takes quite a long time. It might be the case that the user closes the activity and then starts it again, however, the files are not fully saved to disk before the activity is created again. For this reason, on the next launch, the activity contains incorrect data. How can I deal with this issue, i.e. ensure that the data is fully saved to disk before the next launch?</p>