0

android.database.sqlite.SQLiteConstraintException exception in my query

This my query it inserts properly but shows exception

sampleDB.execSQL("INSERT INTO requiredfiles (id, scheduleid, layoutid, status, name, priority,size,checksum) VALUES ('"+ media_id+ "', '"+ scheduleid+ "', '"+ layoutid+ "', '0', '" + url + "', '" + priority + "', '" + size + "', '" + checksum + "');");
9
  • It should be nice if you wrote the complete error message. Commented Aug 7, 2013 at 7:26
  • android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed -- this is my error -- thanks for ur replay Commented Aug 7, 2013 at 9:34
  • Could you also the creation script of your table and the values you try to enter? Commented Aug 7, 2013 at 11:10
  • i am get value from json and inserting in table Commented Aug 8, 2013 at 6:32
  • Yep but the table exists. What's its structure. Are the non nullable fields? Commented Aug 8, 2013 at 8:04

1 Answer 1

1

Well, I already write this despite the lack of information. This error means that a constraint has been violated. It is possible possible that you are inserting a null value into a field that cannot be null or that you intent to set a value to an auto incremental field.

Without knowing anything about the table and the value of the variables, it is impossible to answer more precisely to the question.

Here you can find some tips on how to fix this.

Sign up to request clarification or add additional context in comments.

Comments

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.