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 8033523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:43:34+00:00 2026-06-05T01:43:34+00:00

what can I do about the error code 19? I have posted the LogCat,

  • 0

what can I do about the error code 19? I have posted the LogCat, my DatabaseAdapter (RemindersDbAdapter) and some code of the RemindersEditActivity which I think causes the problem (line 316- 336)

This is my LogCat:

06-05 23:57:53.607: E/AndroidRuntime(549): android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed
06-05 23:57:53.607: E/AndroidRuntime(549):  at android.database.sqlite.SQLiteStatement.native_execute(Native Method)
06-05 23:57:53.607: E/AndroidRuntime(549):  at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:92)
06-05 23:57:53.607: E/AndroidRuntime(549):  at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1810)
06-05 23:57:53.607: E/AndroidRuntime(549):  at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1761)
06-05 23:57:53.607: E/AndroidRuntime(549):  at com.xyz.android.taskreminder.RemindersDbAdapter.updateReminder(RemindersDbAdapter.java:204)
06-05 23:57:53.607: E/AndroidRuntime(549):  at com.xyz.android.taskreminder.ReminderEditActivity.saveState(ReminderEditActivity.java:333)
06-05 23:57:53.607: E/AndroidRuntime(549):  at com.xyz.android.taskreminder.ReminderEditActivity.access$0(ReminderEditActivity.java:316)
06-05 23:57:53.607: E/AndroidRuntime(549):  at com.xyz.android.taskreminder.ReminderEditActivity$3.onClick(ReminderEditActivity.java:161)
06-05 23:57:53.607: E/AndroidRuntime(549):  at android.view.View.performClick(View.java:3511)
06-05 23:57:53.607: E/AndroidRuntime(549):  at android.view.View$PerformClick.run(View.java:14105)
06-05 23:57:53.607: E/AndroidRuntime(549):  at android.os.Handler.handleCallback(Handler.java:605)
06-05 23:57:53.607: E/AndroidRuntime(549):  at android.os.Handler.dispatchMessage(Handler.java:92)
06-05 23:57:53.607: E/AndroidRuntime(549):  at android.os.Looper.loop(Looper.java:137)
06-05 23:57:53.607: E/AndroidRuntime(549):  at android.app.ActivityThread.main(ActivityThread.java:4424)
06-05 23:57:53.607: E/AndroidRuntime(549):  at java.lang.reflect.Method.invokeNative(Native Method)
06-05 23:57:53.607: E/AndroidRuntime(549):  at java.lang.reflect.Method.invoke(Method.java:511)
06-05 23:57:53.607: E/AndroidRuntime(549):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-05 23:57:53.607: E/AndroidRuntime(549):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-05 23:57:53.607: E/AndroidRuntime(549):  at dalvik.system.NativeStart.main(Native Method)

This is my DatabaseAdapter:

public class RemindersDbAdapter {

//
// Databsae Related Constants
//
private static final String DATABASE_NAME = "data";
private static final String DATABASE_TABLE = "reminders";
private static final int DATABASE_VERSION = 10;

public static final String KEY_TITLE = "title";
public static final String KEY_BODY = "body";
public static final String KEY_IMAGE = "image";
public static final String KEY_DATE_TIME = "reminder_date_time"; 
public static final String KEY_ROWID = "_id";


private static final String TAG = "ReminderDbAdapter";
private DatabaseHelper mDbHelper;
private SQLiteDatabase mDb;

/**
 * Database creation SQL statement
 */
private static final String DATABASE_CREATE =
        "create table " + DATABASE_TABLE + " ("
                + KEY_ROWID + " integer primary key autoincrement, "
                + KEY_TITLE + " text not null, " 
                + KEY_BODY + " text not null, " 
                + KEY_IMAGE + " text not null, "
                + KEY_DATE_TIME + " text not null);"; 



private final Context mCtx;

private static class DatabaseHelper extends SQLiteOpenHelper {

    DatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {

        db.execSQL(DATABASE_CREATE);
        db.execSQL("PRAGMA foreign_keys = OFF;");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
                + newVersion + ", which will destroy all old data");
        db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE);
        onCreate(db);
    }
}

/**
 * Constructor - takes the context to allow the database to be
 * opened/created
 * 
 * @param ctx the Context within which to work
 */
public RemindersDbAdapter(Context ctx) {
    this.mCtx = ctx;
}

public RemindersDbAdapter open() throws SQLException {
    mDbHelper = new DatabaseHelper(mCtx);
    mDb = mDbHelper.getWritableDatabase();
    return this;
}

public void close() {
    mDbHelper.close();
}


public long createReminder(String title, String body, String path, String reminderDateTime) {
    ContentValues initialValues = new ContentValues();
    initialValues.put(KEY_TITLE, title);
    initialValues.put(KEY_BODY, body);
    initialValues.put(KEY_IMAGE, path);   
    initialValues.put(KEY_DATE_TIME, reminderDateTime); 

    return mDb.insert(DATABASE_TABLE, null, initialValues);
}

public boolean deleteReminder(long rowId) {

    return mDb.delete(DATABASE_TABLE, KEY_ROWID + "=" + rowId, null) > 0;
}


public Cursor fetchAllReminders() {

    return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_TITLE,
            KEY_BODY, KEY_IMAGE, KEY_DATE_TIME}, null, null, null, null, null);
}


public Cursor fetchReminder(long rowId) throws SQLException {

    Cursor mCursor =

            mDb.query(true, DATABASE_TABLE, new String[] {KEY_ROWID,
                    KEY_TITLE, KEY_BODY, KEY_IMAGE, KEY_DATE_TIME}, KEY_ROWID + "=" + rowId, null,
                    null, null, null, null);
    if (mCursor != null) {
        mCursor.moveToFirst();
    }
    return mCursor;

}

// Fetches a single image
public Cursor fetchImage(long rowId) throws SQLException {

    Cursor mCursor =

            mDb.query(true, DATABASE_TABLE, new String[] {KEY_ROWID,
                    KEY_IMAGE}, KEY_ROWID + "=" + rowId, null,
                    null, null, null, null);
    if (mCursor != null) {
        mCursor.moveToFirst();
    }
    return mCursor;

}



public boolean updateReminder(long rowId, String title, String body, String path, String reminderDateTime) {
    ContentValues args = new ContentValues();
    args.put(KEY_TITLE, title);
    args.put(KEY_BODY, body);
    args.put(KEY_IMAGE, path);
    args.put(KEY_DATE_TIME, reminderDateTime);

    return mDb.update(DATABASE_TABLE, args, KEY_ROWID + "=" + rowId, null) > 0;
}

}

This is line 316- 336 of my RemindersEditActivity:

//
// Saves the content by communicating with the RemindersDbAdapter.
//
private void saveState() {
    String title = mTitleText.getText().toString();
    String body = mBodyText.getText().toString();

    String path = (String)mImageView.getTag();

    SimpleDateFormat dateTimeFormat = new SimpleDateFormat(DATE_TIME_FORMAT);
    String reminderDateTime = dateTimeFormat.format(mCalendar.getTime());

    // Creates a new reminder if the value is null.
    if (mRowId == null) {
        long id = mDbHelper.createReminder(title, body, path, reminderDateTime);
        if (id > 0) {
            mRowId = id;
        } 
    // Updates the reminder if the content is not null.     
    } else {
        mDbHelper.updateReminder(mRowId, title, body, path, reminderDateTime);

    }
}
  • 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-06-05T01:43:35+00:00Added an answer on June 5, 2026 at 1:43 am

    Well, the only constraint you have is “not null”, so try not inserting a column with a null value.

    It’s coming from your update, so use the debugger to check all the parameters coming in for a null.

    You other option is of course to remove the not null constraint (requires updating/recreating the DB).

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

Sidebar

Related Questions

Hello Can Any one have idea about below code and its related error. code:
can anyone give me any advice on what to do about this error ?!
I posted a question to the DBunit mailing list about an error I see
I have a table generated from some PHP code that lists a SMALL amount
I recently posted a question here about some memory issues I was having. I've
I have problem when i using ListView and Linq as datasource. The error down:
I inherited some partially complete sql code that I can't get to work. it
I have a question about error/exception handling on the iPhone. I've read the documentation
I posted earlier about how to do this, and got some great replies, and
Say that I have the Python code: someString = file(filename.jpg).read() How can I replicate

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.