Activity / process lifecycle - when to save/load data to/from disk
<p>My app is made of two activities, A and B. I'm considering this sequence of steps:</p>

<ul>
<li>Activity A is started.</li>
<li>A launches B [A is paused, B is running].</li>
<li>B launches a map intent [A and B are both paused now].</li>
</ul>

<p>Now the user is using the maps application and the system decides it needs more memory. Can the system kill <strong>only one</strong> of my activities for memory, or will it always kill <strong>all</strong> activities in a "<strong>process</strong>" in this situation? </p>

<p>Both activities share some static data like:</p>

<pre><code>class Data {
    public static String mName;
    public void save() {
      // write to file: mName;
    }
    public void load() {
      // mName = read from file;
    }
}

ActivityA.mTextView.setText(Data.mName);
ActivityB.mListView.addText(Data.mName);
</code></pre>

<p>so when any activity in my app gets onSaveInstanceBundleSate() called, I call Data.save() to write it to disk. Now the question is, in an Activity's onCreate() method, should I simply check to see if Data.mName == null, and if so, assume the Activity is returning from a kill state, and try restoring from disk again? I'm unclear when this restoring should be done, considering Activity A may or may not still be alive etc. - and I don't want to corrupt state if Activity A is still alive but B is coming back from a kill state,</p>

<p>Thanks</p>

<p>Thanks</p>
