1. Are you ready for the Galaxy S20? Here is everything we know so far!

ContactsContract.Contacts issue

Discussion in 'Android Development' started by sourabh_d, Dec 4, 2009.

  1. sourabh_d

    sourabh_d Lurker
    Thread Starter

    Hi

    I am upgrading my contactbook application from 1.6 to 2.0. To retrive the contacts i am using followin code :


    Cursor mCursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI ,null,null,null,null);
    int nameFieldColumnIndex = mCursor.getColumnIndex(PhoneLookup.DISPLAY_NAME);

    String contact = mCursor.getString(nameFieldColumnIndex);

    But it is giving me this exception
    12-04 10:50:05.811: ERROR/AndroidRuntime(582): java.lang.RuntimeException: Unable to start activity ComponentInfo{lgsi.app.pkg/lgsi.app.pkg.ContactActivity}: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 3

    Plz provide some guidelines..
    Thanks,
    Sourabh
     



    1. Download the Forums for Android™ app!


      Download

       
  2. DaveInNYC

    DaveInNYC Member

    Are you sure this is the exact code you were running? Because the error message indicates that there are only 3 columns in the returned cursor, which would not be the case for ContactsContract.Contacts.CONTENT_URI.
     
Loading...
Similar Threads - ContactsContract Contacts issue
  1. TienDat
    Replies:
    0
    Views:
    326
  2. Ronald Seman
    Replies:
    2
    Views:
    284
  3. bobnewman
    Replies:
    7
    Views:
    360
  4. Justme73
    Replies:
    6
    Views:
    481
  5. ewalez331
    Replies:
    6
    Views:
    384
  6. Judy Texan
    Replies:
    1
    Views:
    377
  7. faboi
    Replies:
    2
    Views:
    371
  8. Royce Fickling
    Replies:
    9
    Views:
    415
  9. Carroll
    Replies:
    3
    Views:
    645
  10. App Update
    Replies:
    0
    Views:
    226

Share This Page

Loading...