unreliable result for checking incoming number in contact : i m using code listed here `http://stackoverflow.com/questions/26859338/check-incoming-number-is-stored-in-contacts-list-or-not-android` for checking whether incoming number exist or not in contacts. This code does not give correct result always. Is there some correction required in this or some other better way to check?
Code:

    String res = null;
        try {
            ContentResolver resolver = ctx.getContentResolver();
            Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
            Cursor c = resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME}, null, null, null);
    
            if (c != null) { // cursor not null means number is found contactsTable
                if (c.moveToFirst()) {   // so now find the contact Name
                    res = c.getString(c.getColumnIndex(CommonDataKinds.Phone.DISPLAY_NAME));
                }
                c.close();
            }
        } catch (Exception ex) {
            /* Ignore */
        }        
        return res;