title: How to get hashmap key and value in java from another function
body: <p>I have a json parse like this </p>
  
  <pre><code>public class SecondFragment extends Fragment implements OnClickListener {
  
  
  // URL to get contacts JSON
  private static String contestUrl = "http://api.apps.com/contest";
  
  // JSON Node names
  private static final String TAG_ITEM_ID = "id";    
  private static final String TAG_URL = "url";    
  private static final String TAG_START_DATE = "start_date";    
  private static final String TAG_END_DATE = "end_date";   
  
  // contacts JSONArray
  JSONArray foods = null;
  
  // Hashmap for ListView
  ArrayList&lt;HashMap&lt;String, String&gt;&gt; foodslist;
  
  
  
  }
  
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onActivityCreated(savedInstanceState);
  
      foodslist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
  
  
  
   // Calling async task to get json
      new GetContacts().execute();
  
  }
  
  /**
   * Async task class to get json by making HTTP call
   * */
  private class GetContacts extends AsyncTask&lt;Void, Void, Void&gt; {
      @Override
      protected Void doInBackground(Void... arg0) {
          // Creating service handler class instance
          ServiceHandler sh = new ServiceHandler();
  
          // Making a request to url and getting response
          String jsonStr = sh.makeServiceCall(contestUrl, ServiceHandler.GET);
  
          Log.d("Response: ", "&gt; " + jsonStr);
  
          if (jsonStr != null) {
              try {
  
                  foods = new JSONArray(jsonStr);
  
                  // looping through All Contacts
                  for (int i = 0; i &lt; foods.length(); i++) {
                      JSONObject c = foods.getJSONObject(i);
  
                      String id = c.getString(TAG_ITEM_ID);
                      String name = c.getString(TAG_URL);
                      String email = c.getString(TAG_START_DATE);
                      String address = c.getString(TAG_END_DATE);
  
                      // tmp hashmap for single contact
                      HashMap&lt;String, String&gt; contact = new HashMap&lt;String, String&gt;();
  
                      // adding each child node to HashMap key =&gt; value
                      contact.put(TAG_ITEM_ID, id);
                      contact.put(TAG_URL, name);
                      contact.put(TAG_START_DATE, email);
                      contact.put(TAG_END_DATE, address);
  
                      String start_date = (String)contact.get(TAG_ITEM_ID);
  
                      // adding contact to contact list
                      foodslist.add(contact);
                  }
              } catch (JSONException e) {
                  e.printStackTrace();
              }
          } else {
              Log.e("ServiceHandler", "Couldn't get any data from the url");
          }
  
          return null;
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I have two function, <code>onCreate</code> and <code>GetContacts</code>. In the end of <code>onCreate</code> it call <code>GetContacts</code> and call this json.</p>
  
  <p>My question is, how can I got the <code>Hashmap</code> value on <code>GetContacts</code> so I can use it on <code>onCreate</code></p>
  
  <p>So far, I got this to get the value of <code>Hashmap</code></p>
  
  <p><code>String start_date = (String)contact.get(TAG_ITEM_ID);</code></p>
  
  <p>But, its only works on <code>GetContacts</code>.
  Anyone can help me?</p>
  
  <p>Thanks Before</p>