java.lang.IllegalArgumentException: column '_id' does not exist

前端 未结 5 1520
暖寄归人
暖寄归人 2020-12-15 16:37

I\'m trying to debug my application on a real device but I get this error:

ERROR/AndroidRuntime(981): Caused by: java.lang.IllegalArgumentException:

5条回答
  •  悲哀的现实
    2020-12-15 17:06

    You are trying to use a cursor that REQUIRES a column called _id. Its as simple as editing your table creation statement and adding a column called _id.

    Its declartion looks something like this:

    _id INTEGER PRIMARY KEY AUTOINCREMENT
    

    Add this and you will then be able to use it. I believe this is a requirement that is required in order to use a SimpleCursorAdapter.

    UPDATE

    "CREATE TABLE IF NOT EXISTS contact_data( _id INTEGER PRIMARY KEY AUTOINCREMENT, contact_id INTEGER, contact_name VARCHAR(50), number_type VARCHAR(50), contact_number VARCHAR(50), duration TIME, duration_sum TIME, date DATE, current_time TIME, cont INTEGER, type VARCHAR, month VARCHAR(50), day VARCHAR(50), year VARCHAR(50));"
    

    Solution: add a space between the left parenthesis '(' and _id

提交回复
热议问题