title: How to know if fragment has been recreated
body: <p>I need to display some data in ListFragment. I'm downloading data from internet with AsyncTask and then update data with Adapter.</p>
  
  <pre><code>public void onActivityCreated(Bundle savedInstanceState) {
  
      super.onActivityCreated(savedInstanceState);
      activity = getActivity();
      context = activity.getApplicationContext();
      res = activity.getResources();
      resFactory = createFactory(context);
      dataFolder = resFactory.getDataFolder();
      dataFile = resFactory.getDataFile();
      ArrayList list = resFactory.getArrayList();
      setListAdapter(resFactory.getAdapter(context, list));
      linkToData = resFactory.getDataLink(res);
      getData();
  
  }
  </code></pre>
  
  <p>in <code>getData</code> I'm starting <code>AsyncTask</code>.</p>
  
  <p>I want <code>getData</code> to be executed only once inside one user session. So if fragment was detached and then attached again, I don't want to download data again. But if fragment was just created I want it to download data.</p>
  
  <p>The simple answer to that would be call <code>getData</code> from <code>onCreate()</code>, but then I get nullPointer, because at that point I have no <code>AsyncTask</code>. So I need to somehow to know whether fragment was just have been created or it was just detached and then attached again.</p>
  
  <p>English is not my native language. So I'm sorry If my question is not very understandable.</p>