Primary key for Android songs?

Can someone tell me how to declare a composite primary key in Android 1.6 which includes an autoincrement _id column? I am not sure of the syntax. As a result, I just used it in Java when I try to add values ​​(where dateNumber + date must be unique in the table):

Cursor fuelUpsCursor = getFuelUps(registrationNumber, date); if(!fuelUpsCursor.moveToNext()) { //add registrationNumber and date } 

I really don’t need the _id column, but it can make life difficult if the tables do not.

Cheers, Barry

+4
source share
1 answer

Your question does not make much sense. The subject line prompts for a "composite foreign key", your first sentence asks for a "composite primary key" with AUTOINCREMENT , which then ignores your sample code.

I am going to interpret your question this way: you want the _ID INTEGER PRIMARY KEY AUTOINCREMENT in your table to be able to use the Android CursorAdapter , but you must also be sure that the combination of the other two columns is unique.

In this case, I think you want to use the UNIQUE :

+5
source

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


All Articles