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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:08:44+00:00 2026-06-15T11:08:44+00:00

In Android 4.2, using SQLite 3.7.11, when I delete a row from the Quizzes

  • 0

In Android 4.2, using SQLite 3.7.11, when I delete a row from the Quizzes table, who’s schema is below, the corresponding rows in the QuizQuestions table are not deleted.

I can’t figure out what’s wrong. I have tried putting

db.execSQL("PRAGMA foreign_keys = ON;"); 

before and after the create table statements.

Create table statements:

CREATE TABLE quizzes(quiz_name TEXT PRIMARY KEY COLLATE NOCASE);

CREATE TABLE quizQuestions(quiz_name TEXT, question_id INTEGER,
     PRIMARY KEY(quiz_name, question_id),
     FOREIGN KEY(quiz_name) REFERENCES quizzes(quiz_name) ON DELETE CASCADE,
     FOREIGN KEY(question_id) REFERENCES questions(question_id) ON DELETE CASCADE);
  • 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-15T11:08:46+00:00Added an answer on June 15, 2026 at 11:08 am

    Your database should delete rows from quizQuestions in case someone is deleting from quizzes or from questions. It will ignore the entire foreign key constraint in case foreign key support is turned off and you have just regular columns that can contain any value.

    SQLite defaults to PRAGMA foreign_keys = OFF every time you open the database. It’s not a property of a table or of the schema.

    In case you use SQLiteOpenHelper put it in onOpen. That is the place that is called every time the database is opened. onCreate only once when the database is created.


    What SQLiteOpenHelper calls when you call getWriteableDatabase for the first time is

    1. onConfigure every time, API Level >= 16 required
    2. depending on the existence and version of the database file the following is called within an transaction
      • onCreate if there is no database file. Typically, this happens only once in the entire lifetime of the app.
      • onUpgrade if the database version (PRAGMA user_version – saved inside the database file) is less then the version supplied in SQLiteOpenHelper’s constructor. Happens every time you bump the version in your code.
      • Nothing if file exists and version matches.
    3. onOpen every time

    If the same instance of SQLiteOpenHelper already has an open database it will just return it and nothing of above happens.

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

Sidebar

Related Questions

everyone. This is a piece of code from using sqlite in android tutorial: return
I'm using sqlite in android app and I want to make insert in table
How do I get the row count of a query in Android using SQLite?
I am using sqlite in my android application. When i delete all the records
I am using sqlite database in Android. I'm not creating any database I'm using
My Android app is using an SQLite FTS3 table to provide full text search.
I am using Android 2.1 SDK, the application reads from the Sqlite database, a
I'm using sqlite version 3.7 for my android application, I'm just not sure despite
If I create an android database using SQLite it will be local, just for
I was newbie in using sqlite database android. and now I have a problem

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.