Install ListView Adapter with Composite PRIMARY KEY in SQLite Table

I linked data from a SQLite database table to a ListView with SimpleCursorAdapter. This works well when I use _id INTEGER PRIMARY KEY AUTOINCREMENTmy table as the primary key. However, I am trying to use a composite primary key, for example:

CREATE TABLE table (
column1,
column2,
column3,
PRIMARY KEY (column1, column2));

From what I can assemble, the constructor SimpleCursorAdapterrequires the _id column to work. I cannot find a way to build SimpleCursorAdapterusing a composite primary key.

+3
source share
1 answer

Just copy them to your raw request as _ID

select column1 || '_' || column2 as _ID, column1, column2,column3 from table
0
source

Source: https://habr.com/ru/post/1758115/


All Articles