ContactsContract.Contacts issue


Last Updated:

  1. sourabh_d

    sourabh_d Member This Topic's Starter

    Joined:
    Oct 29, 2009
    Messages:
    5
    Likes Received:
    0
    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
     

    Advertisement
  2. DaveInNYC

    DaveInNYC Well-Known Member

    Joined:
    Nov 7, 2009
    Messages:
    52
    Likes Received:
    3
    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.
     

Share This Page

Loading...