I have phone number. Is there any way to check whether the phone number exists in contacts database in the device or not? Depending on that I need have move further in my ap
I tried the code above on an ice cream device (SIII) and it didnt work so after some search i ended up creating this method (which is working nicely )
private boolean isContact(String incommingNumber) {
Cursor cursor =null;
String name = null;
try {
Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(incommingNumber));
cursor = MainService.this.getContentResolver().query(uri, new String[] { PhoneLookup.DISPLAY_NAME }, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
name = cursor.getString(cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME));
}
} finally {
if(cursor!=null){
cursor.close();
}
}
return Util.hasValue(name);
}