Hi all,

   I am trying to write a simple function that determines if a contact
has a phone number or not. And am not having any luck what so ever. I
have tried several ways of achieving this all found online. At present
I have the following:


public boolean hasPhone() {
        Cursor phones = getContentResolver().query(
                ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                null,
                ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "=" +
this.getId(),
                null,
                null
        );
        boolean has = false;
        if(phones.getCount() > 0) {
             has = true;
        }
        if(!phones.isClosed()) {
              phones.close();
        }
        return has;
}

The function above always returns false, I know the 'getId()' method
returns the contacts actual id, as the class has other similar
functions that return the correct contacts data.

Any advice would be greatly appreciated.

Thanks,
Lee.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to