Reputation: 189
I'm trying to get all the contacts which has number that starts with some query.
contactLookup = getContentResolver().query(
Data.CONTENT_URI,
new String[] { Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL },
Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "' and "
+ ContactsContract.CommonDataKinds.Phone.NUMBER + " like ?",
new String[] { "%" + query + "%" }, null);
if (contactLookup != null && contactLookup.getCount() > 0) {
contactLookup.moveToNext();
String number = contactLookup.getString(contactLookup.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
Log.v("debug", number);
contactLookup.getString(contactLookup.getColumnIndex(BaseColumns._ID));
}
The number is 123-456-789 but my query string is 123456. How do i compare only number without formatting characters.
Upvotes: 2
Views: 314