title: Get contact details from contact id in Android
body: <p>I want to get several contact details from a contact list view. I have this code:</p>
  
  <pre><code>list.setOnItemClickListener(new OnItemClickListener() {
  
  @Override
  public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long id) {
          //HERE I WANT TO GET CONTACT DETAILS FROM THE ID PARAMETER
  
          Uri lookupUri = Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, Uri.encode(id));
          Cursor c = getContentResolver().query(lookupUri, new String[]{Contacts.DISPLAY_NAME}, null,null,null);
          try {
                c.moveToFirst();
                String displayName = c.getString(0);
          } finally {
                c.close();
          }
  
  }
  </code></pre>
  
  <p>But I get this exception: IllegalArgumentException, Invalid lookup id (when I call query method from cursor).
  So I dont know how to get a valid lookup id from the item list.</p>
  
  <p>Any idea? thanks!</p>