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

  • SEARCH
  • Home
  • 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 8722659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:27:42+00:00 2026-06-13T07:27:42+00:00

I have a proble with a SqliteConstraintException. My db is like that private static

  • 0

I have a proble with a SqliteConstraintException.
My db is like that

private static final String CREATE_TABLE_1 =
   "create table table_1 (uid integer primary key autoincrement, "
+ table_1.c1 + " TEXT,"
+ table_1.c2 + " integer,"
+ table_1.c3 + " TEXT," 
+ table_1.c4 + " TEXT,"
+ table_1.c5 + " integer);";

private static final String CREATE_TABLE_2 = 
        "create table table_2 (uid integer primary key autoincrement, "
+ table_2.c1 + " TEXT,"
+ table_2.c2 + " integer,"
+ table_2.c3 + " TEXT);";

private static final String CREATE_TABLE_3 = 
        "create table table_3 (uid integer primary key autoincrement, "
        + "uid_table_1 integer, "
        + "uid_table_2 integer, "

+ "FOREIGN KEY(uid_table_1) REFERENCES table_1(uid) ON DELETE CASCADE, " 
+ "FOREIGN KEY(uid_table_2) REFERENCES table_2(uid) ON DELETE CASCADE);";

private static final String CREATE_TABLE_4 = 
        "create table table_4 (uid integer primary key autoincrement, "
+ "uid_table_2 integer,"
+ "FOREIGN KEY(uid_table_2) REFERENCES table_2(uid) ON DELETE CASCADE);";

And i use in my SQLiteOpenHelper to enable foreign key constraints

@Override
public void onOpen(SQLiteDatabase db) {
super.onOpen(db);
if (!db.isReadOnly()) {
// Enable foreign key constraints
db.execSQL("PRAGMA foreign_keys=ON;");
}

But when i want to delete on row of the table_2, i get SqliteConstraintException.
Can you help me please ?

Thank you

  • 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-13T07:27:43+00:00Added an answer on June 13, 2026 at 7:27 am

    I looks like most of your tables reference each other. if you want to delete a row in Table 2 that is used as the foreign key in a different table, you need to delete the records that reference it. so delete records from tables 3 and 4 that have a foreign key reference to the row you are trying to delete in 2 and THEN call delete for that row.

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

Sidebar

Related Questions

I have a config.php that is included to each page. In config I create
i have one doubt, that is when we create one-to-many as bidirectional. we will
I have problem with Activities navigation, searching works good. Activities hierarchy looks like that:
i have a proble, when insert something in foreign language into database. i have
Hi i have a proble in finding solution. I have 3 tables: Customer customer_id
We have now installed Agilo to manage our Scrum projects, and we have that
I am wordking on a site, made with wordpress, and i like to have
I have Service custom control that doesn't need to be visual. I just add
first of all thanks for reading. I have a web application that heavily uses
I want to capitalise the first letter of a string. That part is done.

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.