title: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 2
body: <p>Below is my codes and I got the <code>android.database.CursorIndexOutOfBoundsException</code>: Index -1 requested, with a size of 2 error. Can anyone tell me how to solve it?</p>
  
  <pre><code>ContentResolver cr = getContentResolver();
    Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,
      null, null, null, null);
    if (Integer.parseInt(cur.getString(
      cur.getColumnIndex(People.PRIMARY_PHONE_ID))) &gt; 0) {
  
     Cursor pCur = cr.query(
       Contacts.Phones.CONTENT_URI, 
       null, 
       Contacts.Phones.PERSON_ID +" = ?", 
       new String[]{id}, null);
     int i=0;
     int pCount = pCur.getCount();
     String[] phoneNum = new String[pCount];
     String[] phoneType = new String[pCount];
     while (pCur.moveToNext()) {
      phoneNum[i] = pCur.getString(
        pCur.getColumnIndex(Contacts.Phones.NUMBER));
      phoneType[i] = pCur.getString(
        pCur.getColumnIndex(Contacts.Phones.TYPE));
      i++;
     } 
    }
   }
  }
  </code></pre>