title: Retrofit method response reusing into another activity
body: <p>How can I get the data from  getDataForId(Integer.toString(1));  by calling the same getDataForId method from the DisplayData class?</p>
  
  <p>I want reuse the same method and get the result.
  It doesn't make sense to copy and paste the same method into the other activity class. Then there will be the same code repeated twice.</p>
  
  <p>This is my DisplayData.class</p>
  
  <pre><code>  public class DisplayData extends AppCompatActivity {
  
      Detail reqDetail;
      String BASE_URL = "";
      TextView name;
  
      ImageView image;
  
      @Override
      protected void onCreate(@Nullable Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.display_data);
  
          name = (TextView) findViewById(R.id.name);
  
          image = (ImageView)findViewById(R.id.image);
  
  
  
          public void getDataForId(final String id) {
  
          ApiInterface apiInterface = APIClient.getApiInterface();
          Call&lt;MyResponse&gt; call = apiInterface.getResponse();
          call.enqueue(new Callback&lt;MyResponse&gt;() {
  
          @Override
          public void onResponse(Call&lt;MyResponse&gt; call, Response&lt;MyResponse&gt; response) {
  
                 if (response.body() != null) {
                  MyResponse myResponse = response.body();
                      List&lt;Detail&gt; details = myResponse.getDetails();
                          for (Detail d : details) {
                              if (d.getId().equals(id)) {
                                  reqDetail = d;
                                      name.setText(reqDetail.getName());
  
                                              Picasso.with(DisplayData.this)
                                              .load(reqDetail.getName())
                                              .placeholder(R.mipmap.ic_launcher)
                                              .error(R.mipmap.ic_launcher)
                                              .into(image);
                                              }
                                          }
  
                                      }
                                  }
  
              @Override
              public void onFailure(Call&lt;MyResponse&gt; call, Throwable t) {
  
              }
          });
      }
  </code></pre>
  
  <p>This is my SecondData class where I want to display the same data response of DisplayData by reusing same methods</p>
  
  <pre><code>public class SecondData extends AppCompatActivity {
  
      Detail reqDetail;
      String BASE_URL = "";
      TextView name;
  
      ImageView image;
  
      @Override
      protected void onCreate(@Nullable Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.second_main);
  
          name = (TextView) findViewById(R.id.name);
  
          image = (ImageView)findViewById(R.id.image);
  
  
  
      }
  
  
  }
  </code></pre>