I am trying to get Viber contacts. Using this method i get the name of the contacts that use Viber but also other contacts that do not use Viber (the selection method is not working properly) .I cant get the Viber contacts number also. Any idea how can i resolve this issue?
Cursor cursor2 = getContentResolver().query(ContactsContract.RawContacts.CONTENT_URI
,null
, ContactsContract.RawContacts.ACCOUNT_TYPE_AND_DATA_SET + "= ?"
,new String[] { "com.viber.voip" }
, null);
while (cursor2.moveToNext())
{
String name=cursor2.getString(cursor2.getColumnIndex(ContactsContract.RawContacts.DISPLAY_NAME_PRIMARY));
//Adding contact name into the ArrayList
myViberContacts.add(name+"\n");
//Giving the TextView the value of the arraylist
emervib.setText(myViberContacts.toString());