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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:58:00+00:00 2026-06-11T19:58:00+00:00

Is there any documentation on how to best deal with database upgrades in android?

  • 0

Is there any documentation on how to best deal with database upgrades in android?

I am developing an application and have been testing it on my own telephone. All works fine, over the past few deploys I had to add some columns to my table and due to upgrade statements that are executed if the old database version is lesser then a certain database version.

However when I try to run the application on another phone, that gives errors due to the fact that there is no previous version and thus the column isn’t added.

Is there any best practice or documentation on how to handle database upgrading and versioning? I tried googling around for specific questions, but much good didn’t come out of that.

Here’s the relevant code I am using at the moment:

private static final int DATABASE_VERSION = 11;

private static class LocalLoginDatabaseHelper extends SQLiteOpenHelper {
    LocalLoginDatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }
    @Override
    public void onCreate(SQLiteDatabase db) {
        Log.d(TAG,DATABASE_CREATE);
        db.execSQL(DATABASE_CREATE);
    }
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        if(oldVersion < 11) {
            Log.d(TAG + "Upgrade",DATABASE_ALTER);
            db.execSQL(DATABASE_ALTER);
        }
    }
}

Thanks

  • 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-11T19:58:01+00:00Added an answer on June 11, 2026 at 7:58 pm

    Is there any documentation on how to best deal with database upgrades in android?

    Use SQLiteOpenHelper, which will give you control when a schema change is detected, so you can upgrade the database.


    UPDATE

    However when I try to run the application on another phone, that gives errors due to the fact that there is no previous version and thus the column isn’t added.

    Your DATABASE_CREATE needs to have the column as well. For a new install (or after the user does Clear Data on your app), there is no existing database, and so onCreate(), not onUpgrade(), is called.

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

Sidebar

Related Questions

I have to maintain an old project without documentation, and there is a database
Is there any documentation on Mustache best practices when using on the server (with
Is there any documentation on principles behind using URIs on Android platform? For example,
Is there any good documentation on implementing new refactorings in Eclipse? Specifically, I'd like
I'm wondering if there is any shortcut in visual studio to generate automatic documentation
We're developing a system to replace an old application from our clients. Actually there
I am wondering what the best practices in developing an application where an external
I have been searching around the web all day for the best way to
The official documentation states the following: . But I have noticed that there are
Is there any detailed documentation of the INI options of Z3. I had to

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.