Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3397766
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:34:05+00:00 2026-05-18T04:34:05+00:00

android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed error in my application and not sure why.

  • 0

android.database.sqlite.SQLiteConstraintException:
error code 19: constraint failed

error in my application and not sure why.

It happens when i add a new Inbox item into my database.

here is the Create statement of my inbox table:

CREATE TABLE inbox (uid text, title text, sender text, timeRecieved text, PRIMARY KEY(uid));

implemented using these static final Strings;

public static final String LABEL_INBOX_UID = "uid";
    public static final String LABEL_INBOX_TITLE = "title";
    public static final String LABEL_INBOX_SENDER = "sender";
    public static final String LABEL_INBOX_TIME_RECIEVED = "timeRecieved";

    public static final int COLUMN_INBOX_UID = 0;
    public static final int COLUMN_INBOX_TITLE  = 1;
    public static final int COLUMN_INBOX_SENDER= 2;
    public static final int COLUMN_INBOX_TIME_RECIEVED = 3;

    public static final String TABLE_NAME_INBOX = "inbox";
    public static final String TABLE_CREATE_INBOX = "CREATE TABLE "
        + TABLE_NAME_INBOX + " (" + LABEL_INBOX_UID + " text, "
        + LABEL_INBOX_TITLE + " text, " + LABEL_INBOX_SENDER
        + " text, " + LABEL_INBOX_TIME_RECIEVED + " text, "
     + "PRIMARY KEY(" + LABEL_INBOX_UID + ")" + ");";

And here is the method that gets a inbox item and put it inside a contentValues()

@Override
    protected void insertItem(InboxListItem object, String table) {
        InboxListItem item = object;
        inboxItemValue = new ContentValues();

        inboxItemValue.put(LABEL_INBOX_UID, item.getUid()); 
        Log.d(TAG, "item.getUid() " + item.getUid());
        inboxItemValue.put(LABEL_INBOX_TIME_RECIEVED, item.getTimeRecieved());
        Log.d(TAG, "item.getTimeRecieved() " + item.getTimeRecieved());
        inboxItemValue.put(LABEL_INBOX_TITLE, item.getTitle());
        Log.d(TAG, "item.getTitle() " + item.getTitle());
        inboxItemValue.put(LABEL_INBOX_SENDER, item.getSender());
        Log.d(TAG, "item.getSender() " + item.getSender());


        Log.d(TAG, "TABLE_CREATE_EVENTS =" + TABLE_CREATE_EVENTS);
        Log.d(TAG, "TABLE_CREATE_INBOX =" + TABLE_CREATE_INBOX);
        Log.d(TAG, "TABLE_CREATE_CONTACTS =" + TABLE_CREATE_CONTACTS);
        database().insert(TABLE_NAME_INBOX, null, inboxItemValue);
        Log.d(TAG, "database().insert(TABLE_NAME_INBOX, null, inboxItemValue);");


    }

O and here is the full exception message:

11-22 12:24:39.606:
ERROR/Database(773): Error inserting
sender=Mit Technology Review
uid=663b074a-16c8-46fb-a420-e0ebf716e212
title=Emerging Technologies Friday
Update (11/19/2010)
timeRecieved=2010-11-19T06:02:36.000Z
11-22 12:24:39.606:
ERROR/Database(773):
android.database.sqlite.SQLiteConstraintException:
error code 19: constraint failed 11-22
12:24:39.606: ERROR/Database(773):
at
android.database.sqlite.SQLiteStatement.native_execute(Native
Method) 11-22 12:24:39.606:
ERROR/Database(773): at
android.database.sqlite.SQLiteStatement.execute(SQLiteStatement.java:55)
11-22 12:24:39.606:
ERROR/Database(773): at
android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1549)
11-22 12:24:39.606:
ERROR/Database(773): at
android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1410)
11-22 12:24:39.606:
ERROR/Database(773): at
com.kc.database.InboxDbWrapper.insertItem(InboxDbWrapper.java:44)
11-22 12:24:39.606:
ERROR/Database(773): at
com.kc.database.InboxDbWrapper.insertItem(InboxDbWrapper.java:1)
11-22 12:24:39.606:
ERROR/Database(773): at
com.kc.database.DbWrapper.insertAllItemsToDb(DbWrapper.java:42)
11-22 12:24:39.606:
ERROR/Database(773): at
com.kc.database.InboxDbWrapper.populateTable(InboxDbWrapper.java:54)
11-22 12:24:39.606:
ERROR/Database(773): at
com.kc.main.screen.HomeMainScreenOne.loadDataToDb(HomeMainScreenOne.java:225)
11-22 12:24:39.606:
ERROR/Database(773): at
com.kc.main.screen.AbstractMainScreen.onCreate(AbstractMainScreen.java:125)
11-22 12:24:39.606:
ERROR/Database(773): at
com.kc.main.screen.HomeMainScreenOne.onCreate(HomeMainScreenOne.java:51)
11-22 12:24:39.606:
ERROR/Database(773): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-22 12:24:39.606:
ERROR/Database(773): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-22 12:24:39.606:
ERROR/Database(773): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-22 12:24:39.606:
ERROR/Database(773): at
android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-22 12:24:39.606:
ERROR/Database(773): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-22 12:24:39.606:
ERROR/Database(773): at
android.os.Handler.dispatchMessage(Handler.java:99)
11-22 12:24:39.606:
ERROR/Database(773): at
android.os.Looper.loop(Looper.java:123)
11-22 12:24:39.606:
ERROR/Database(773): at
android.app.ActivityThread.main(ActivityThread.java:4627)
11-22 12:24:39.606:
ERROR/Database(773): at
java.lang.reflect.Method.invokeNative(Native
Method) 11-22 12:24:39.606:
ERROR/Database(773): at
java.lang.reflect.Method.invoke(Method.java:521)
11-22 12:24:39.606:
ERROR/Database(773): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-22 12:24:39.606:
ERROR/Database(773): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-22 12:24:39.606:
ERROR/Database(773): at
dalvik.system.NativeStart.main(Native
Method)

Thanks in advance:

Edit: Somemore info. I had previously created a events and contactsList table succesfully and that seems to work fine. here is the code below:

Contacts:

// Variables used to create the events table
    public static final String TABLE_NAME_CONTACTS = "contactsList";

    public static final String LABEL_CONTACTS_UID = "uid";
    public static final String LABEL_CONTACTS_FULLNAME = "fullname";

    public static final String TABLE_CREATE_CONTACTS = "CREATE TABLE "
            + TABLE_NAME_CONTACTS + " (" + LABEL_CONTACTS_UID + " text, "
            + LABEL_CONTACTS_FULLNAME + " text, " + "PRIMARY KEY("
            + LABEL_CONTACTS_UID + ")" + ");";


    public static final int COLUMN_CONTACTS_UID = 0;
public static final int COLUMN_CONTACTS_FULLNAME = 1;

CREATE TABLE contactsList (uid text, fullname text, PRIMARY KEY(uid));

calendar events:

public static final String LABEL_EVENTS_UID = "uid";
    public static final String LABEL_EVENTS_TITLE = "title";
    public static final String LABEL_EVENTS_LOCATION = "location";
    public static final String LABEL_EVENTS_DATE = "date";
    public static final String LABEL_EVENTS_TIME = "time";
    public static final String LABEL_EVENTS_TIMEZONE = "timezone";

    public static final int COLUMN_EVENTS_UID = 0;
    public static final int COLUMN_EVENTS_TITLE = 1;
    public static final int COLUMN_EVENTS_LOCATION = 2;
    public static final int COLUMN_EVENTS_DATE = 3;
    public static final int COLUMN_EVENTS_TIME = 4;
    public static final int COLUMN_EVENTS_TIMEZONE = 5;

    // Variables used to create the events table
    public static final String TABLE_NAME_EVENTS = "events";
    public static final String TABLE_CREATE_EVENTS = "CREATE TABLE "
            + TABLE_NAME_EVENTS + " (" + LABEL_EVENTS_UID + " text, "
            + LABEL_EVENTS_TITLE + " varchar(30), " + LABEL_EVENTS_LOCATION
            + " varchar(30), " + LABEL_EVENTS_DATE + " varchar(30), "
            + LABEL_EVENTS_TIME + " varchar(30), " + LABEL_EVENTS_TIMEZONE
            + " varchar(30), " + "PRIMARY KEY(" + LABEL_EVENTS_UID + ")" + ");";

CREATE TABLE events (uid text, title varchar(30), location varchar(30), date varchar(30), time varchar(30), timezone varchar(30), PRIMARY KEY(uid));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:34:05+00:00Added an answer on May 18, 2026 at 4:34 am

    The only constraint on your table is the primary key, so you’re probably trying to insert an item with a non-unique ‘UID’.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get frequently SQLiteDoneException, 06-29 02:03:34.816: WARN/System.err(30470): android.database.sqlite.SQLiteDoneException: not an error 06-29 02:03:34.816: WARN/System.err(30470):
I know that on Android there is android.database.sqlite package that provides helpful classes to
I've got an android app using a local sqlite database. private SQLiteDatabase mDb; when
I am using SQLite in a project used by an android application. Currently I
When I add this code to my Android 2.1 Java app, it fails: db=SQLiteDatabase.openOrCreateDatabase(Locations,
In my Android application, when I rotate the device (slide out the keyboard) then
I have two threads in an Android application, one is the view thread, and
I open a sqlite database and use rawquery to get data. But the log.e
I created a sqlite database to store playlists for a media player I am
How can I edit an SQLite database after it has been created and stored

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.