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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:07:11+00:00 2026-05-29T09:07:11+00:00

I have a little issue with upgrading my sqlite database. For now I’m using

  • 0

I have a little issue with upgrading my sqlite database. For now I’m using this :

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    Log.w("","UPGRADE DATABASE : "+" oldVErsion : "+oldVersion+" newVersion : "+newVersion);
    switch(newVersion){
    case 2:
        Log.w("","UPGRADE DATABASE : "+newVersion);
        db.execSQL("ALTER TABLE collection_lang ADD COLUMN bonus_text VARCHAR(200)");
        db.execSQL("ALTER TABLE collection_lang ADD COLUMN quantity integer");
    case 3:
        Log.w("","UPGRADE DATABASE : "+newVersion);
        db.execSQL("ALTER TABLE users ADD COLUMN firstName varchar(70)");
        db.execSQL("ALTER TABLE users ADD COLUMN lastName varchar(70)");
        db.execSQL("ALTER TABLE users ADD COLUMN user varchar(70)");
    }
}

It’s working if you already have the application installed from the beggining..but if you install it now, it will run queries only in case 3, because the current version is 3.

I need to find a way to run the queries from the beginning.. if my last version of database is 5, I want to run first the case 2, than case 3, than 4 and at last case 5. So I won’t need to write all the queries from the beginning because it will crash for the old users.

Any ideas how to achieve this?

  • 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-05-29T09:07:12+00:00Added an answer on May 29, 2026 at 9:07 am

    Just add your queries from the case 2 into the case 3 and add break statement after each case. So in your case it will be something like this:

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        Log.w("","UPGRADE DATABASE : "+" oldVErsion : "+oldVersion+" newVersion : "+newVersion);
        switch(newVersion){
        case 2:
            Log.w("","UPGRADE DATABASE : "+newVersion);
            db.execSQL("ALTER TABLE collection_lang ADD COLUMN bonus_text VARCHAR(200)");
            db.execSQL("ALTER TABLE collection_lang ADD COLUMN quantity integer");
            break;
        case 3:
            Log.w("","UPGRADE DATABASE : "+newVersion);
            db.execSQL("ALTER TABLE collection_lang ADD COLUMN bonus_text VARCHAR(200)");
            db.execSQL("ALTER TABLE collection_lang ADD COLUMN quantity integer");
            db.execSQL("ALTER TABLE users ADD COLUMN firstName varchar(70)");
            db.execSQL("ALTER TABLE users ADD COLUMN lastName varchar(70)");
            db.execSQL("ALTER TABLE users ADD COLUMN user varchar(70)");
            break;
        }
    }
    

    Update: Do smthg like this:

    switch(newVersion){
    case 2:
        Log.w("","UPGRADE DATABASE : "+newVersion);
        db.execSQL("ALTER TABLE collection_lang ADD COLUMN bonus_text VARCHAR(200)");
        db.execSQL("ALTER TABLE collection_lang ADD COLUMN quantity integer");
        break;
    case 3:
        Log.w("","UPGRADE DATABASE : "+newVersion);
        switch(oldVersion) {
            case 1:
                db.execSQL("ALTER TABLE collection_lang ADD COLUMN bonus_text VARCHAR(200)");
                db.execSQL("ALTER TABLE collection_lang ADD COLUMN quantity integer");
                db.execSQL("ALTER TABLE users ADD COLUMN firstName varchar(70)");
                db.execSQL("ALTER TABLE users ADD COLUMN lastName varchar(70)");
                db.execSQL("ALTER TABLE users ADD COLUMN user varchar(70)");
                break;
            case 2: 
                db.execSQL("ALTER TABLE users ADD COLUMN firstName varchar(70)");
                db.execSQL("ALTER TABLE users ADD COLUMN lastName varchar(70)");
                db.execSQL("ALTER TABLE users ADD COLUMN user varchar(70)");
                break;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have little issue with detecting internet connection while using static IP on device.
I have a strange little issue with a WCF RIA service I'm using in
This little issue is starting to do my head in, I have read around
I have a little issue with setting an image to a list view using
I have this tiny little issue with the datagrid. In my grid I have
Hey most of my issue has been solved but i have little problem This
I have a little issue using SVN. When I run svn stat I get
I have a little issue right now and its bugging me, hopefully one of
I have a little issue with Java UTF-8 converting.I have this Objective C code
I have a little issue with my code which I am using to read

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.