views:

99

answers:

0

Hi guys,

I am trying to write a method that determines if a contact has at least one phone number, at the moment I have this:

public boolean hasPhone() {
 Cursor phones = this.map.getContentResolver().query(
  ContactsContract.Contacts.CONTENT_URI,
  null,
  ContactsContract.Contacts._ID + "=" + this.contactId,
  null,
  null
 );
 boolean has = false;
 if(phones.moveToFirst()) {
  do {        
    if(Integer.parseInt(phones.getString(phones.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
      has = true;
      break;
    }
  } while(phones.moveToNext());
 }
 return has;
}

the method always returns false, even though I know the contact in question has a phone number. Also I know the contactId is correct as I also use it to get the postal address, etc.

Any help would be greatly appreciated, as I am about to tear my hair out :p

Thanks.