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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:01:43+00:00 2026-06-12T14:01:43+00:00

I implemented a ContentProvider for my android app and it works very well but

  • 0

I implemented a ContentProvider for my android app and it works very well but when I make some changes to the schema, the database doesn’t seem to be upgraded.
I have the following code in my SQLiteOpenHelper :

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    Log.w(DEBUG_TAG, "Upgrading database. Existing contents will be lost. ["
        + oldVersion + "]->[" + newVersion + "]");
    db.execSQL("DROP TABLE IF EXISTS " + TABLE_TUTORIALS);
    onCreate(db);
}

If I update my app with a new schema then all my inserts fail BUT if I uninstall the old version and install the new version of the app then everything works fine. So I guess that onUpgrade() is never called. What do oldVersion and newVersion refer to? Do I need to specify the version anywhere?

  • 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-12T14:01:44+00:00Added an answer on June 12, 2026 at 2:01 pm

    SQLiteOpenHelper has a version argument, if you increment onUpgrade should be called:

    public SQLiteOpenHelper (Context context, String name, SQLiteDatabase.CursorFactory factory, int version)
    

    For example I have the following class and if I increment dbVersion it is called:

    public class DBHelper extends SQLiteOpenHelper {
    
        private SQLiteDatabase m_Db;
    
        public DBHelper(Context context, String dbPath, int dbVersion) {
    
            super(context, dbPath, null, dbVersion);
            ...
            m_Db = getWritableDatabase();
        }
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I implemented some code using backbone.js in Asp.NEt MVC3 and found backbone.js very helpful.
I have a normal SQLite database in my app, managed through my own ContentProvider
I implemented the Facebook registration on my website. Everything works fine except that suddenly
We implemented In-app Billing one year ago with no problems following the sample code
I implemented Adwhirl into my new universal app. And was able to get the
I'm building an android app where I basically implement a music player from a
my android application is handling a large database of bus passage time and we
I cannot export nor build my android app because of an error in proguard.cfg.
I'm implementing a ContentProvider and when I implement the query method, I'm facing some
I'm building an Android client for an Internet discussion board: the app downloads the

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.