IllegalStateException: couldn't read row 0, col -1 from cursorWindow

前端 未结 1 1078
一生所求
一生所求 2021-01-29 06:12

IllegalStateException: couldn\'t read row 0, col -1 from cursorWindow. I am new to android I looked at smiller question did solve my problem help please Thanks in advance.

1条回答
  •  伪装坚强ぢ
    2021-01-29 07:06

    The column name you gave does not exists.

    getColumnIndex(String columnName)
    

    Returns the zero-based index for the given column name, or -1 if the column doesn't exist.
    Error lies in any of the following parts of your code:

    c.getString(c.getColumnIndex("Expense_Category ")); //notice the space after Expense_Category
    c.getString(c.getColumnIndex("Amount"));
    c.getString(c.getColumnIndex("PaymentType"));
    c.getString(c.getColumnIndex("Date"));
    

    If you expect the column to exist use getColumnIndexOrThrow(String) instead, which will make the error more clear.

    0 讨论(0)
提交回复
热议问题