Phone type and Email type not working?
<p>The phone type and Email type in my project has some problem.I am using 2.1 platform, there was no problem in my project before adding the Phone type and the Email type, after using these Phone type and Email type when I try to run the project it open a message box and shows application stopped and force close. My xml file has a Button and the ListView. i am using this code.</p>

<p><strong>code</strong></p>

<pre><code> public class GetAllDatas extends Activity {

ListView lvItem;
private Button btnAdd;
String Ptype, Etype;
int contactPhoneType;

String displayName="", emailAddress="", phoneNumber="";
ArrayList&lt;String&gt; contactlist=new ArrayList&lt;String&gt;(); 
ArrayAdapter&lt;String&gt; itemAdapter;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    lvItem = (ListView)this.findViewById(R.id.lvitems); 
    btnAdd = (Button)this.findViewById(R.id.btnAddItem);

    itemAdapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1,contactlist);
    lvItem.setAdapter(itemAdapter);

    btnAdd.setOnClickListener(new View.OnClickListener() { 
        public void onClick(View v) {
            readContacts();
        }
    });

} 

private void readContacts()
{
    ContentResolver cr =getContentResolver();
    Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);


    while (cursor.moveToNext()) 
    {
        displayName  = "" ;
        ArrayList&lt;String&gt; phoneNumber  = new ArrayList&lt;String&gt;();
        ArrayList&lt;String&gt; emailAddress  = new ArrayList&lt;String&gt;();

        displayName = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));       
        String id = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));

        /*                   Email                   */ 

        Cursor emails = cr.query(Email.CONTENT_URI,null,Email.CONTACT_ID + " = " + id, null, null);
        while (emails.moveToNext()) 
        { 
            emailAddress.add(emails.getString(emails.getColumnIndex(Email.DATA)));

        } 

         contactPhoneType = emails.getInt(emails.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE));

        switch(contactPhoneType){
        case ContactsContract.CommonDataKinds.Phone.TYPE_HOME: 
        Etype = "Home";
        break;

        }


        emails.close(); 


      /*            Phone Number and Type   */ 

        if(Integer.parseInt(cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) &gt; 0)
        {
            Cursor pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,null,ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?",new String[]{id}, null);
           while (pCur.moveToNext()) 
            {
                 phoneNumber.add(pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));                               
           }

            contactPhoneType = pCur.getInt(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE));


           switch(contactPhoneType){
           case ContactsContract.CommonDataKinds.Phone.TYPE_HOME: 
           Ptype = "Home";
           break;

           }


            pCur.close();  
        }   

int phoneNumberCount = phoneNumber.size();
int emailCount = emailAddress.size();

// Add arraylist data to contactlist..

if(phoneNumberCount &gt; emailCount) {

    for (int i=0; i&lt;phoneNumberCount; i++)
      {
        if(emailCount&gt;i)
          {
           contactlist.add(displayName +  " , " +  Ptype + " , " + phoneNumber.get(i) + " , " + Etype + " , " + emailAddress.get(i) + "\n");    
           }
        else
        {
          contactlist.add(displayName + " , " +  Ptype + " , " + phoneNumber.get(i) + " , " + " , " + "\n");
        } 
       }
    }
    else  
       {
        for (int i=0; i&lt;emailCount; i++) 
         {
        if(phoneNumberCount&gt;i)
          {
            contactlist.add(displayName + " , " + Ptype + " , " + phoneNumber.get(i) + " , " +  Etype + " , " + emailAddress.get(i) + "\n"); 
          }
        else
        { 
          contactlist.add(displayName + " , " + " , " + " , " + Etype + " , " + emailAddress.get(i) +  "\n");
        }
      }
    }      
    }
    Collections.sort(contactlist);
    itemAdapter.notifyDataSetChanged();
    cursor.close(); 
} 
</code></pre>

<p>}</p>

<p><strong>Logcat</strong></p>

<pre><code>06-26 13:31:16.213: E/AndroidRuntime(449): Uncaught handler: thread main exiting due to   uncaught exception
06-26 13:31:16.224: E/AndroidRuntime(449): android.database.CursorIndexOutOfBoundsException: Index 1 requested, with a size of 1
06-26 13:31:16.224: E/AndroidRuntime(449):  at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)
06-26 13:31:16.224: E/AndroidRuntime(449):  at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214)
06-26 13:31:16.224: E/AndroidRuntime(449):  at android.database.AbstractWindowedCursor.getInt(AbstractWindowedCursor.java:84)
06-26 13:31:16.224: E/AndroidRuntime(449):  at android.database.CursorWrapper.getInt(CursorWrapper.java:123)
06-26 13:31:16.224: E/AndroidRuntime(449):  at com.abhi.GetAllDatas.readContacts(GetAllDatas.java:71)
06-26 13:31:16.224: E/AndroidRuntime(449):  at com.abhi.GetAllDatas.access$0(GetAllDatas.java:47)
06-26 13:31:16.224: E/AndroidRuntime(449):  at com.abhi.GetAllDatas$1.onClick(GetAllDatas.java:41)
</code></pre>
