The details of the contacts not displayed properly by using this code. I am trying to access the Name, Number and Email ID by using the Intent. Name and Number only displayed when I click the button but not the Email.No error in the project.It's working good.My xml file have only one Button.
public class GetDetails extends Activity {
/** Called when the activity is first created. */
private static final int CONTACT_PICKER_RESULT = 1001; 
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
       Button Btn = (Button)findViewById(R.id.getContacts);
        Btn.setOnClickListener(new View.OnClickListener() { 
            @Override 
            public void onClick(View v) {
                Intent i = new Intent(Intent.ACTION_PICK,ContactsContract.CommonDataKinds.Phone.CONTENT_URI);
                startActivityForResult(i, CONTACT_PICKER_RESULT);
            } 
        });
    }
    protected void onActivityResult(int reqCode, int resultCode, Intent data) { 
        super.onActivityResult(reqCode, resultCode, data);
        if(resultCode == RESULT_OK) {
            switch (reqCode) {
            case CONTACT_PICKER_RESULT:
                Cursor cursor = null;
                Cursor emails = null;
                String number = "";
                String emailID = "";
                try {
                    Uri result = data.getData();
                    //get the id from the uri
                    String id = result.getLastPathSegment();  
                    //query
                    cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,null,ContactsContract.CommonDataKinds.Phone._ID + " = ? " , new String[] {id}, null);
                    int numberIdx = cursor.getColumnIndex(Phone.DATA);  
                     if(cursor.moveToFirst()) {
                        number = cursor.getString(numberIdx);
                    } else {
                    }
                      emails = getContentResolver().query(Email.CONTENT_URI,null,Email.CONTACT_ID + " = " + id, null, null);
                     int num = emails.getColumnIndex(Email.DATA);
                     if(emails.moveToFirst()) {
                         emailID = emails.getString(num);
                     } else { 
                     }
                } catch (Exception e) {
                    //failed
                } finally {
                    if (cursor!=null) {
                        cursor.close();
                    }
                }
            }
        }
    }
}
How to solve this situation ?