title: Android fetch all contact list (name, email, phone) takes more then a minute for about 700 contacts
body: <p>Is there any way to shorten this time? 
  I'm running with the cursor and takes the name, phone numbers and emails</p>
  
  <p>if I remove the phone numbers query from the query loop it ends in 3 seconds</p>
  
  <p>any idea how can I improve that query?</p>
  
  <p>Maybe I'm doing something wrong in my query?</p>
  
  <p>(Obviously I'm doing it async but still... it's a very long time that a user can't wait)</p>
  
  <p>Hope someone can share his thoughts about this</p>
  
  <p>this is my code</p>
  
  <pre><code>ContentResolver cr = getContentResolver();
              Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,
                      null, null, null, null);
              if (cur.getCount() &gt; 0) {
                  while (cur.moveToNext()) {
                      AddressBookEntity adr = new AddressBookEntity();
                      String id = cur.getString(cur
                              .getColumnIndex(ContactsContract.Contacts._ID));
                      String name = cur
                              .getString(cur
                                      .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
                      adr.fullName = name;
  
                      Cursor emailCur = cr
                              .query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,
                                      null,
                                      ContactsContract.CommonDataKinds.Email.CONTACT_ID
                                              + " = ?", new String[] { id },
                                      null);
                      while (emailCur.moveToNext()) {
                          // This would allow you get several email addresses
                          // if the email addresses were stored in an array
                          String email = emailCur
                                  .getString(emailCur
                                          .getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
                          if (!Utils.IsNullOrEmptyString(email)) {
                              adr.email = email;
                          }
  
                      }
                      emailCur.close();
  
                      if (Integer
                              .parseInt(cur.getString(cur
                                      .getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) &gt; 0) {
                          Cursor pCur = cr
                                  .query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                                          null,
                                          ContactsContract.CommonDataKinds.Phone.CONTACT_ID
                                                  + " = ?",
                                          new String[] { id }, null);
                          int phoneIndex = 0;
                          while (pCur.moveToNext()) {
                              String number = pCur.getString(pCur
                                      .getColumnIndex(Phone.NUMBER));
  
                              String country = Utils.GetCountryFromNumber(
                                      number, app);
                              number = Utils.GetFullPhoneNumber(number, app);
                              if (phoneIndex == 0) {
                                  if (!Utils.IsNullOrEmptyString(number)) {
                                      adr.contactAdressBookId = id;
                                      adr.phoneNumber = number;
                                      adr.userInsertedId = app.userCred.userId;
                                      adr.country = country;
                                      myContacts.add(adr);
                                  }
                              } else {
                                  if (!Utils.IsNullOrEmptyString(number)) {
                                      AddressBookEntity adrMore = new AddressBookEntity();
                                      adrMore.fullName = adrMore.fullName;
                                      adrMore.country = adrMore.country;
                                      adrMore.email = adrMore.email;
                                      adrMore.phoneNumber = number;
                                      adrMore.contactAdressBookId = id;
                                      adrMore.country = country;
                                      myContacts.add(adrMore);
                                  }
                              }
                          }
                          pCur.close();
                      }
                  }
                  cur.close();
  </code></pre>