I am trying to fetch only email contacts that are available in my contacts. Right now I have got a solution that shows all the contacts and if selected contacts doesn't have an email address it would toast stating no email address found. Instead I would like to show contacts that has only email address.
Here is the query that I tried:
Cursor cursor = null;  
            String emailid = "";
            List<String> allids = new ArrayList<String>();
            int emailIds = 0;
            try 
            {  
                Uri result = data.getData();  
                String id = result.getLastPathSegment();  
                Log.e("Email","TRY"+emailid);
                cursor = getContentResolver().query(Email.CONTENT_URI, null, Email.CONTACT_ID + "=?", new String[] { id }, null);                   
                /*cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Email.CONTENT_URI, null, ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = ?", 
                new String[]{id}, null);*/
                emailIds = cursor.getColumnIndex(Email.DATA);
                if (cursor.moveToFirst()) 
                {
                    while (cursor.isAfterLast() == false)
                    {
                        emailid = cursor.getString(emailIdx);
                        allids.add(emailid);
                        cursor.moveToNext();
                    }
                } 
                else 
                {
                    //no results actions
                }  
            }
Can somebody let me know how to get email query part working?
Thanks!