Avoiding time consuming data loading during Fragment rotation
<p>I want to avoid time consuming data loading during <code>Fragment</code> rotation.</p>

<pre><code>public class WatchlistFragment extends SherlockListFragment {
    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        if (savedInstanceState == null) {
            data = getTimeConsumingData();          
        } else {
            Log.i(TAG, "savedInstanceState is not null!");
            // Avoid performing time consuming data operation during rotation changes.
            // But I never have chance to reach here !?!?
            data = savedInstanceState.getStringArray("data");
        }
        setListAdapter(new ArrayAdapter&lt;String&gt;(getActivity(), android.R.layout.simple_list_item_1, data));
    }

    public String[] getTimeConsumingData() {
        Log.i(TAG, "WatchlistFragment getTimeConsumingData");
        return new String[] { "A", "B", "C"};
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        Log.i(TAG, "WatchlistFragment onSaveInstanceState");
        super.onSaveInstanceState(outState);
        outState.putStringArray("data", data);
    }

    private String[] data = null;
    private static final String TAG = WatchlistFragment.class.getSimpleName();
}
</code></pre>

<p>Strangely, <code>savedInstanceState</code> in <code>onActivityCreated</code> is always null even I perform several rotation.</p>

<p>Note, I prefer not to use <code>setRetainInstance(true)</code> as described <a href="http://stackoverflow.com/questions/11853389/android-fragments-retaining-data">Android Fragments Retaining Data</a> The author is using <code>onSaveInstanceState</code>. Just that I'm not sure why mine doesn't work.</p>
