title: Right Approach to Call Web Service(API) from Fragment class
body: <p>I need to know, In which fragment callback method, we should call a web service by which after come back to fragment web service should not call again.</p>
  
  <p>For example.
  I have a fragment class MyFragment.java </p>
  
  <pre><code>public class MyFragment extends Fragment {
  
  
      @Override
      public void onAttach(Activity activity) {
          super.onAttach(activity);
  
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          View rootView = inflater.inflate(R.layout.fragment_layout, container,
                  false);
  
          return rootView;
      }
  
  }
  </code></pre>
  
  <p>I need to know which callback method I have to call webservice to update the UI of fragment. <strong>Right Now I am calling web services from <code>onCreateView</code> method</strong>. but I need to know what should be best way to call web service from fragment.</p>