Unable to fetch correct email while contact name and number are correct
<p>i am new to android, i want to get email of existing contact in my contact list every time i use the below code i could not get the exact email of contact but any random email.
please help me to correct this code i will be very thankful.</p>

<pre><code> public void fetchingContacts(Context context) {

            Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
            ContentResolver cr = context.getContentResolver();
            Cursor crsr = cr.query(uri, null, null, null, null);

            crsr.moveToFirst();

            if (crsr.getCount() &gt; 0) {
                while (crsr.moveToNext()) {
                    ID = crsr
                            .getString(crsr
                                    .getColumnIndex(ContactsContract.CommonDataKinds.Phone._ID));
                    id = crsr.getString(crsr.getColumnIndex(BaseColumns._ID));
                    NAME = crsr
                            .getString(crsr
                                    .getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
                    NUMBER = crsr
                            .getString(crsr
                                    .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));

                    arylist_contact_id.add(ID);
                    arylist_all_number.add(NUMBER);
                    arylist_all_names.add(NAME);
                    // ////////////



                    Cursor emailCur = cr.query(
                            ContactsContract.CommonDataKinds.Email.CONTENT_URI,
                            null, ContactsContract.CommonDataKinds.Email.CONTACT_ID
                                    + " = " + id, null, null);

                    while (emailCur.moveToNext()) {
                        email = emailCur
                                .getString(emailCur
                                        .getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));

                        Log.v("fetchingEMAIL ---  ", email);

                    }
                    emailCur.close();


                    Log.v("IN do while :: name and number ", ID + " , id :" + id
                            + "  " + NAME + " : " + NUMBER + "  :  " + email);
                } 

            }
            crsr.close();
        }
</code></pre>
