android.database.CursorIndexOutOfBoundsException: Index -1 requested

After you execute query, you must call cur.moveToFirst()

Try this

ContentResolver cr = getContentResolver();
        Cursor cur = cr.query(Contacts.CONTENT_URI, 
       null, null, null, null);

if(cur != null && cur.moveToFirst())
{
       String id = cur.getString(cur.getColumnIndex(Contacts._ID));

        if (cur.getCount() > 0) {
         ...

Leave a Comment