title: Getting android contacts
body: <p>Im trying to get a list of all the contacts and there email address. </p>
  
  <p>Currently im using this code, however I get a lot of duplicate names and emails. What i want is just one person and one email. Is there a way I can merge contacts while querying for them?</p>
  
  <p>Also im just looking for a > 2.0 solution. </p>
  
  <pre><code>    private void init() {
  
      ContentResolver cr = getContentResolver();
      Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,null, null, null, null);
      if (cur.getCount() &gt; 0) {
      while (cur.moveToNext()) {
          String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
      String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
          Cursor emailCur = cr.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,null,ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = ?", new String[]{id},null); 
          while (emailCur.moveToNext()) { 
                  String email = emailCur.getString( emailCur.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
                  Log.e("Email",name+" "+email);
              } 
              emailCur.close();
          }
  
      }
  </code></pre>