CursorIndexOutOfBoundsException problem:Index 4 requested, with a size of 4

后端 未结 3 1414
走了就别回头了
走了就别回头了 2021-01-24 05:02

I want to display for each maker an AlertDialog that has some description, for that, i\'m using this code:

protected boolean onTap(int index) {
            db =          


        
3条回答
  •  礼貌的吻别
    2021-01-24 06:00

    Array indexing starts with 0, not 1. your fourth element is stored at index 3.

    When i put cur.moveToPosition(index); under String description = cur.getString(cur.getColumnIndexOrThrow("description")); i have Index -1 requested, with a size of 4 otherwise, like above code Index 4 requested, with a size of 4

    When the row set is first returned the cursor will be at positon -1, which is before the first row.

提交回复
热议问题