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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:21:16+00:00 2026-06-14T17:21:16+00:00

in my dbHelper : onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) function I save one

  • 0

in my dbHelper:

onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) 

function I save one table to an external database.

Therefore I

  1. attach and copy to the external database
  2. delete the db file in this function and copy it from external
  3. restore from external database to db.

this works until the function returns to getWritableDatabase()

Here I get this exception:

java.lang.IllegalStateException: no transaction pending

What is wrong? Thanks
Tata

  • 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-14T17:21:17+00:00Added an answer on June 14, 2026 at 5:21 pm

    The issue is that the onUpgrade method (as well as onCreate) occurs within a transaction, and at the end sets the transaction to be successful and ends it.

    However, you have already ended the transaction in onUpgrade, resulting in this error.

    Relevant code from SQLiteOpenHelper:

            ...
            if (version != mNewVersion) {
                db.beginTransaction();
                try {
                    if (version == 0) {
                        onCreate(db);
                    } else {
                        onUpgrade(db, version, mNewVersion);
                    }
                    db.setVersion(mNewVersion);
                    db.setTransactionSuccessful();
                } finally {
                    db.endTransaction();
                }
            }
            ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {} DBHelper function(implementing SQLite
I'm attempting to update my database table with the following code: public void onUpgrade(SQLiteDatabase
i have one table TABLE_SUBJECT And i pass subject name to DBHelper.java. Then i
I’m using a database helper to update a table with one row and two
I'm trying to pass my dbhelper instance from one activity to another using this
Exception: CREATE TABLE android_metadata failed Failed to setLocale() when constructing, closing the database android.database.sqlite.SQLiteException:
Hi friends. I'm trying to store some data into a 2-table-database. Here is its
In my app I have a dbhelper class where everything in my database happens,
I am new sqlite. I have one table that having 3 columns 1. Id
Can someone explain how the onUpgrade function is called within the SqliteDbOpenHelper class. I'm

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.