Unable to INSERT in SQLite, Error code:19

constraint failed

Sounds like your primary key already exists in the table


I had the same problem and Pentium 10's answer led me in the correct direction. After verifying the bellow code was wrong then correcting it I cleared data from that app in the emulator and it recreated the DB and it works fine now.

     "create table if not exists " + DATABASE_TABLE + " (" + _ID + " integer primary key autoincrement," +
     " ItemName text not null, ItemID text not null, Image text not null, ImageDate text not null);";

I think one of my problems was I had an extra column. I removed one of the columns earlier and did not remove it from the above lines.

The main thing is tripple check the code for errors and spelling and if using the emulator clear the data.


You can remove the not null from table and it will work fine. like this:
right:

String callTable = "CREATE TABLE IF NOT EXISTS '%s'" + "(userid VARCHAR, callwith VARCHAR, calltype VARCHAR, callstart time, callend time, callmedia VARCHAR" + ");"

wrong:

String callTable = "CREATE TABLE IF NOT EXISTS '%s'" + "(userid VARCHAR not Null , callwith VARCHAR not null, calltype VARCHAR, callstart time, callend time, callmedia VARCHAR" + ");"