Hi all.
return False... also if number exit.
Any idea ??
Thank you all
B4X:
public final static boolean existNumber(BA ba, String phoneNumber){
boolean exist = false;
try{
ContentResolver contentResolver = ba.context.getContentResolver();
Cursor cursor = contentResolver.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
if (cursor.getCount() > 0) {
while (cursor.moveToNext()) {
String contact_id = cursor.getString(cursor.getColumnIndex( ContactsContract.Contacts._ID ));
int hasPhoneNumber = Integer.parseInt(cursor.getString(cursor.getColumnIndex( ContactsContract.Contacts.HAS_PHONE_NUMBER )));
if (hasPhoneNumber > 0) {
Cursor phoneCursor = contentResolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", new String[] { contact_id }, null);
while (phoneCursor.moveToNext()) {
String phoneNumberContact = phoneCursor.getString(phoneCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
if(phoneNumber.equals(phoneNumberContact)){
exist = true;
phoneCursor.close();
cursor.close();
return exist;
}
}
phoneCursor.close();
}
}
}
cursor.close();
}catch(Exception e){
exist = false;
if(DEBUG) Log.e("Exception", e.toString());
}
return exist;
}
return False... also if number exit.
Any idea ??
Thank you all
Last edited: