Alternatives to using onRetainNonConfigurationInstance
<p>I have an app that potentially tracks a large amount of data during app use for a single player, and my app can allow up to 5 players at a time, which means this large amount of data is potentially multiplied times 5.</p>

<p>I write all of the data to my SQLite database when the Activity is destroyed, and this works fine.</p>

<p>The problem occurs during an orientation change. I used onRetainNonConfigurationInstance because I thought that I could at least rely on it for orientation changes, but what I have found is that other things going on within Android can wipe out my data. Some examples reported by users:</p>

<pre><code>- While the app was running, the user took a phone call. After returning to the app, the data was gone.
- While the app was running, another user downloaded an update to a different app from the Market, and found the data gone after returning to the app.
- While the app was running, another user started a different app (a music player), and returned to find the data gone.
</code></pre>

<p>I know that the use of onRetainNonConfigurationInstance is the problem because my app initially wrote each individual data field for each player to a bundle, and while the app was implemented that way, no problems were encountered over the course of many months.</p>

<p>As soon as I found out about onRetainNonConfigurationInstance and used that for my implementation, I started receiving complaints.</p>

<p>My implementation is simple. I implement as follows:</p>

<pre><code>@Override
public Object onRetainNonConfigurationInstance()
{
    return mPlayers;  //array of player objects
}
</code></pre>

<p>Then in onCreate, I do this:</p>

<pre><code>mPlayers = (PlayerData [])getLastNonConfigurationInstance();
</code></pre>

<p>Since there appears to be some underlying problem, what is the best alternative for retaining large amounts of user data across screen rotations?</p>

<p>Thanks for any assistance!</p>
