title: how to get id value from listview on the ClickListener
body: <p>I want to get the id from the <code>listview</code>, not the position. The id is in the JSON file so while I am displaying the data in a <code>listview</code> so when I click on it I get the id of that driver from JSON file.</p>
  
  <blockquote>
    <p>[{lastName=wdkj fsj, firstName=jf jfn, id=1}, {lastName=singh,
    firstName=sunny, id=2}]</p>
  </blockquote>
  
  <pre><code>public class DriverData extends AppCompatActivity {
      private String TAG = DriverData.class.getSimpleName();
  
      ArrayAdapter&lt;String&gt; adapter;
      private ProgressDialog pDialog;
      private ListView lv;
  
  
      // URL to get contacts JSON
      private static String url = "http://54.148.120.200:3000/getDrivers";
  
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; contactList;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.driver_data);
  
          contactList = new ArrayList&lt;&gt;();
          lv = (ListView) findViewById(R.id.simpleListView);
  
  
          new DriverData.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 onPreExecute() {
              super.onPreExecute();
              // Showing progress dialog
              pDialog = new ProgressDialog(DriverData.this);
              pDialog.setMessage("Please wait...");
              pDialog.setCancelable(false);
              pDialog.show();
  
          }
  
          @Override
          protected Void doInBackground(Void... arg0) {
              HttpHandler sh = new HttpHandler();
  
              // Making a request to url and getting response
              String jsonStr = sh.makeServiceCall(url);
  
              Log.e(TAG, "Response from url: " + jsonStr);
  
              if (jsonStr != null) {
                  try {
                      JSONObject jsonObj = new JSONObject(jsonStr);
  
                      // Getting JSON Array node
                      JSONArray contacts = jsonObj.getJSONArray("drivers");
  
                      // looping through All Contacts
                      for (int i = 0; i &lt; contacts.length(); i++) {
                          JSONObject c = contacts.getJSONObject(i);
  
                          String id = c.getString("id");
                          JSONObject user = c.getJSONObject("user");
                          String firstName = user.getString("firstName");
                          String lastName = user.getString("lastName");
  
  
                          // Phone node is JSON Object
  
  
                          // tmp hash map for single contact
                          HashMap&lt;String, String&gt; contact = new HashMap&lt;&gt;();
  
                          // adding each child node to HashMap key =&gt; value
                          contact.put("id", id);
                          contact.put("firstName", firstName);
                          contact.put("lastName", lastName);
  
                          // adding contact to contact list
                          contactList.add(contact);
  
  
                      }
                  } catch (final JSONException e) {
                      Log.e(TAG, "Json parsing error: " + e.getMessage());
                      runOnUiThread(new Runnable() {
                          @Override
                          public void run() {
                              Toast.makeText(getApplicationContext(),
                                      "Json parsing error: " + e.getMessage(),
                                      Toast.LENGTH_LONG)
                                      .show();
                          }
                      });
  
                  }
              } else {
                  Log.e(TAG, "Couldn't get json from server.");
                  runOnUiThread(new Runnable() {
                      @Override
                      public void run() {
                          Toast.makeText(getApplicationContext(),
                                  "Couldn't get json from server. Check LogCat for possible errors!",
                                  Toast.LENGTH_LONG)
                                  .show();
                      }
                  });
  
              }
              System.out.println(contactList);
              return null;
          }
  
          @Override
          protected void onPostExecute(Void result) {
              super.onPostExecute(result);
  
              // Dismiss the progress dialog
              if (pDialog.isShowing())
                  pDialog.dismiss();
  
  
  
              /**
               * Updating parsed JSON data into ListView
               * */
  
              ListAdapter adapter = new SimpleAdapter(
                      DriverData.this, contactList,
                      R.layout.list_item, new String[]{"firstName", "lastName"
              }, new int[]{R.id.name, R.id.lastName});
              lv.setAdapter(adapter);
  
              lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                  @Override
                  public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int position, long l) {
  
                  }
              });
  
          }
      }
  }
  </code></pre>