Hi i want to get contact which are used by other application (like whatsapp or viber ) please see in below image
myWhatsappContacts ArrayList will contain all the phone numbers that are present in your whatsapp Application.
Cursor cursor = getContentResolver().query(ContactsContract.Data.CONTENT_URI
,new String[] {ContactsContract.Data._ID
,ContactsContract.Data.DISPLAY_NAME
,ContactsContract.CommonDataKinds.Phone.NUMBER
,ContactsContract.CommonDataKinds.Phone.TYPE}
,ContactsContract.Data.MIMETYPE + "='" + ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE
+ "' AND " + ContactsContract.RawContacts.ACCOUNT_TYPE + "= ?"
,new String[] { "com.whatsapp" }
, null);
while (cursor.moveToNext())
{
myWhatsappContacts.add(cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
}