How to Get Contact name, number and email ID from a list of Contacts?
<p>I need to do get the details of all contacts when I press a Button, but my details include only 3 details</p>

<ol>
<li><p>Contact Name</p></li>
<li><p>Contact number and </p></li>
<li><p>Email ID </p></li>
</ol>

<p>I am using this code to get Contact name and number of all contacts, here is the code in my Button click </p>

<pre><code>import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;  
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.view.View;
import android.widget.Button;

public class GetNameNumberActivity 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;
                String number = "";
                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 {

                    }
                } catch (Exception e) {
                    //failed
                } finally {
                    if (cursor!=null) {
                        cursor.close();
                    }


                }

            }
        }
    }
}
</code></pre>

<p>With this code how can I add the section for getting email address.</p>
