title: How to read Phone Number in Android from Contacts?
body: <p>I have tried number of combinations but its showing error when I am finding Phone Number
  Here is my code:</p>
  
  <pre><code>public void readPhoneLookUp(){
          Cursor people = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
          //people.moveToFirst();
          while(people.moveToNext()) {
                 int nameFieldColumnIndex = people.getColumnIndex(PhoneLookup.DISPLAY_NAME);
                 String contact = people.getString(nameFieldColumnIndex);
                 Log.i(LOG, "Contacts: "+ contact);
                 int numberFieldColumnIndex = people.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
                 String number = people.getString(numberFieldColumnIndex);
                 Log.i(LOG, "Number: "+ number);
              }
      }//readPhoneLookUp ends
  </code></pre>
  
  <p>I have also added <strong>READCONTACTS permission</strong> in the Manifest
  I have also tried this :</p>
  
  <pre><code>public void readContactsNew(){
          ArrayList&lt;String&gt; contactListArrLst = null;
          contactListArrLst = new ArrayList&lt;String&gt;();
  
          ArrayList&lt;String&gt; contactNumberArrLst = null;
          contactNumberArrLst = new ArrayList&lt;String&gt;();
  
          ContentResolver contentResolver = getContentResolver();
  
          Cursor cursor = contentResolver.query(ContactsContract.Contacts.CONTENT_URI,null, null, null, null);
          int curCount = cursor.getCount();
          Log.i(LOG, "Contacts:Count  "+ curCount);
          cursor.moveToFirst();
          while(!cursor.isAfterLast()){
              contactListArrLst.add(cursor.getString(cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME)));
              contactNumberArrLst.add(cursor.getString(cursor.getColumnIndex(PhoneLookup.NUMBER)));
              cursor.moveToNext();
          }
          cursor.close();
          Log.i(LOG, "Contacts: "+ contactListArrLst);
          Log.i(LOG, "ContactNumber: "+ contactNumberArrLst);
  </code></pre>
  
  <p><strong>But are giving error in contactNumberArrLst</strong></p>
  
  <p>This is the error in the Log Cat:</p>
  
  <pre><code>11-11 10:39:44.231: ERROR/AndroidRuntime(1683): FATAL EXCEPTION: main
  11-11 10:39:44.231: ERROR/AndroidRuntime(1683): java.lang.IllegalStateException: get field slot from row 0 col -1 failed
  11-11 10:39:44.231: ERROR/AndroidRuntime(1683):     at android.database.CursorWindow.getString_native(Native Method)
  11-11 10:39:44.231: ERROR/AndroidRuntime(1683):     at android.database.CursorWindow.getString(CursorWindow.java:361)
  11-11 10:39:44.231: ERROR/AndroidRuntime(1683):     at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:49)
  11-11 10:39:44.231: ERROR/AndroidRuntime(1683):     at android.database.CursorWrapper.getString(CursorWrapper.java:135)
  11-11 10:39:44.231: ERROR/AndroidRuntime(1683):     at com.ravi.conproviderdemo1.ContentProviderDemo1Activity.readPhoneLookUp(ContentProviderDemo1Activity.java:63)
  11-11 10:39:44.231: ERROR/AndroidRuntime(1683):     at com.ravi.conproviderdemo1.ContentProviderDemo1Activity$MyOnClickListener.onClick(ContentProviderDemo1Activity.java:74)
  11-11 10:39:44.231: ERROR/AndroidRuntime(1683):     at android.view.View.performClick(View.java:2408)
  11-11 10:39:44.231: ERROR/AndroidRuntime(1683):     at android.view.View$PerformClick.run(View.java:8816)
  11-11 10:39:44.231: ERROR/AndroidRuntime(1683):     at android.os.Handler.handleCallback(Handler.java:587)
  11-11 10:39:44.231: ERROR/AndroidRuntime(1683):     at android.os.Handler.dispatchMessage(Handler.java:92)
  11-11 10:39:44.231: ERROR/AndroidRuntime(1683):     at android.os.Looper.loop(Looper.java:123)
  11-11 10:39:44.231: ERROR/AndroidRuntime(1683):     at android.app.ActivityThread.main(ActivityThread.java:4633)
  11-11 10:39:44.231: ERROR/AndroidRuntime(1683):     at java.lang.reflect.Method.invokeNative(Native Method)
  11-11 10:39:44.231: ERROR/AndroidRuntime(1683):     at java.lang.reflect.Method.invoke(Method.java:521)
  11-11 10:39:44.231: ERROR/AndroidRuntime(1683):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
  11-11 10:39:44.231: ERROR/AndroidRuntime(1683):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  11-11 10:39:44.231: ERROR/AndroidRuntime(1683):     at dalvik.system.NativeStart.main(Native Method)
  11-11 10:39:44.231: WARN/ActivityManager(174):   Force finishing activity com.ravi.conproviderdemo1/.ContentProviderDemo1Activity
  11-11 10:39:44.401: WARN/AudioFlinger(95): write blocked for 166 msecs, 384 delayed writes, thread 0xbb50
  </code></pre>