Can anyone tell me how to declare a composite primary key in Android 1.6 which includes an autoincrement _id column? I'm not sure of the syntax. I've ended up just enforcing it in Java when I try to add values (where registrationNumber + date has to be unique in the table):
Cursor fuelUpsCursor = getFuelUps(registrationNumber, date);
if(!fuelUpsCursor.moveToNext())
{
//add registrationNumber and date
}
I don't really need the _id column but it can make life tricky if tables don't have one.
Cheers, Barry
`db.execSQL("CREATE TABLE " + FUEL_USE_TABLE_NAME + " (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + REGISTRATION_NO_COLUMN + " TEXT, " + DATE_TIME_COLUMN + " TEXT, UNIQUE (" + REGISTRATION_NO_COLUMN + ", " + DATE_TIME_COLUMN + "));");`
– barry Apr 02 '11 at 13:33`