Android SimpleCursorAdapter No such column Id

后端 未结 4 538
囚心锁ツ
囚心锁ツ 2021-01-20 18:31

I have a Listview that I want to populate with information from my SQLite database with and this seemed like the most practical solution. In my debugger it says it\'s caused

4条回答
  •  醉话见心
    2021-01-20 18:52

    Actually declaring the _id as suggested above will work "_id INTEGER PRIMARY KEY AUTOINCREMENT", but if you don't need _id to be unique over the life of the table, you can omit the AUTOINCREMENT keyword, as the "PRIMARY KEY" will also autoincrement, but is logically equivalently to (max(_id)+1), which guarantees uniqueness which is really what you want when using the CursorAdapter.

提交回复
热议问题