views:

42

answers:

1

I've bound data from a SQLite database table to a ListView using a SimpleCursorAdapter. This works well when I use _id INTEGER PRIMARY KEY AUTOINCREMENT as my table's primary key. However, I'm trying to use a composite primary key such as the following:

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

From what I can gather, the SimpleCursorAdapter constructor requires the _id column to work. I cannot find a way to construct the SimpleCursorAdapter with the composite primary key.

A: 

Just collate them in your raw query as _ID

select column1 || '_' || column2 as _ID, column1, column2,column3 from table
Pentium10
Thanks for the help, but I ended up doing something different. I used INTEGER PRIMARY KEY, without the autoincrement, and had my algorithm construct an _id to pass to the row creation function.
dfetter88