2

this is the error code:

09-27 11:56:01.425: WARN/System.err(10324): android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed
09-27 11:56:01.435: WARN/System.err(10324):     at android.database.sqlite.SQLiteStatement.native_execute(Native Method)
09-27 11:56:01.435: WARN/System.err(10324):     at android.database.sqlite.SQLiteStatement.execute(SQLiteStatement.java:61)
09-27 11:56:01.435: WARN/System.err(10324):     at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1809)
09-27 11:56:01.435: WARN/System.err(10324):     at de.enough.appmate.dbase.CMSResource.updateItem(CMSResource.java:1103)
09-27 11:56:01.435: WARN/System.err(10324):     at de.enough.appmate.dbase.CMSResourceUpdater.updateItems(CMSResourceUpdater.java:178)
09-27 11:56:01.435: WARN/System.err(10324):     at de.enough.appmate.dbase.CMSResourceUpdater.loadUpdates(CMSResourceUpdater.java:102)
09-27 11:56:01.435: WARN/System.err(10324):     at de.enough.appmate.dbase.CMSResourceUpdaterRunnable.run(CMSResourceUpdaterRunnable.java:32)
09-27 11:56:01.435: WARN/System.err(10324):     at java.lang.Thread.run(Thread.java:1019)

and this is the method that is used

this.db.execSQL("INSERT INTO itemGalleryItems (id, imageCaption, imageUrl,itemID,orderIndex,displayInGallery) VALUES (?,?,?,?,?,?); ",
                        bindArgs);

the binArgs looks like:

String[] bindArgs = {
        (String) imageItem.get("id"),
        (String) imageItem.get("imageCaption"),
        (String) imageItem.get("imageName"),
        (String) item.get("id"),
        (String) imageItem.get("orderIndex"),
        (String) imageItem.get("displayInGallery")};

hope someone can help

thanx newone

2
  • in someone field defined the constraint which will not full fill when you insert the value check the constraint. please display your table structure here with so we can see what constraint are failed Commented Sep 27, 2011 at 10:08
  • I had the same problem, but for me, [this][1] worked. [1]: stackoverflow.com/questions/8117685/… Commented May 9, 2013 at 16:58

3 Answers 3

8

I have fixed this error;

instead of

long sucess = db.insert(TABLE_NAME_CONTACT_EXTRA, null, row);

use this to insert data in database

long sucess = db.insertWithOnConflict(TABLE_NAME_CONTACT_EXTRA, null,
                row, SQLiteDatabase.CONFLICT_IGNORE);
Sign up to request clarification or add additional context in comments.

Comments

4

I think if you have autoincrement field, you shouldn't include it in the query... is the "id" autoincrement?

4 Comments

well, try it, just remove the id from the arguments and the query
look here: link
I don't have autoincrement, but I have "text not null" for my columns. Does that matter?
if you have text not null you must provide value for this field
3

Have a look at your insert statement. Does it have all the columns that are declared to be not null in table create statement? And try no to use "id" column, use "_id" instead.

5 Comments

when i change id to _id than I get this failure : android.database.sqlite.SQLiteException: table itemGalleryItems has no column named _id: , while compiling: INSERT INTO itemGalleryItems (_id, imageCaption, imageUrl,itemID,orderIndex,displayInGallery) VALUES (?,?,?,?,?,?);
Changing id to _id was a reccomendation. If you provided an id column name in your table's create statement than you'll have to use id in all other statements.
look here: link
Show your create table statement.
In my case I was not binding a value for primary key. By adding that, I got rid of the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.