title: Proper way to give initial data to fragments?
body: <p>So I've learned that I need an empty constructor in order for my fragments not to crash on reinitialization. My problem is that I use lists of data for my fragments when they are initialized (at least some of them). So what would be a good way to start new fragments with a list of data. Should I in the <code>OnCreate()</code> make a <code>getData</code> method which gets the data from some other source or what would be a proper approach?</p>
  <p>Feeding the bundle with data really wouldn't be a very good approach as I have a lot of data.</p>
  <p>So let's take a case (I understand it tons better that way).</p>
  <p>When a user clicks on a button the fragment is started. What I used to do was creating a new fragment this way:</p>
  <pre><code>    FragmentManager fragmentManager = getSupportFragmentManager();
      FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
      
      fragmentTransaction.replace(R.id.center_container, new DetailFragment(item));
      fragmentTransaction.addToBackStack(DETAIL_TAG);
      
      fragmentTransaction.commit();
  </code></pre>
  <p>Then in my fragment:</p>
  <pre><code>public DetailFragment(EventItem item) {
      mItem = item;
      mPlaces = Database.getContainerPlaces(getActivity()).getValidItems();
  }
  </code></pre>
  <p>I can't give all the data to a bundle, so that wouldn't work. So what should I do?</p>
  <p>A: Should I initialize the fragment with the empty constructor and then from my activity use setters to set the data directly in the fragment? However, won't I be missing data if the user presses home, Android closes the fragment and the user later returns?</p>
  <p>B: Should I initialize the fragment with factory pattern and call <code>setRetainInstance(true)</code>, give the fragment a key for identifying the data, and then letting the fragment fetch the data needed in onCreateView from some third source?</p>
  <p>C: Should I just make an empty constructor and then in <code>onCreate()</code> fetch the data needed for the fragment?</p>
  <p>It should be noted that the app is locked in portrait so the issue is primarily with maintaining the objects when Android closes and the user restarts.</p>