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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:41:35+00:00 2026-06-11T17:41:35+00:00

In my android application i have created the database which contains some data and

  • 0

In my android application i have created the database which contains some data and it is on the app store.Now i need to change the database according to new requirement. when i update the apk file it wont create the new db again because it is already created.

How can i update the database which is already created on users device? How can i call the onUpgread() method of sqlite db? And is there any way to check it on emulator?
Please suggest.Thanks in advance.

 @Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.execSQL("DROP TABLE IF EXISTS " +TABLE_NAME );

      onCreate(db);

}
  • 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-11T17:41:36+00:00Added an answer on June 11, 2026 at 5:41 pm

    The onUpgrade method is called automatically if the database version has been increased.

    When you create a database you supply a version number as an integer to the constructor. Eg.

    public class DatabaseHelper extends SQLiteOpenHelper{
    
    static final String dbName = "myDatabase";
    static int dbVersion = 3;
    
        public DatabaseHelper(Context context) {
            super(context, dbName, null, dbVersion);
    
        }
    
        @Override
        public void onCreate(SQLiteDatabase db) {
            // Create database
        }
    

    If you increase dbVersion above, when the database is created again it will see that the number has increased because it keeps track of the current version number you send through. An increase in the value will trigger onUpgrade and run through that code.

    In your onUpgrade method you can specify what to do between different version numbers. For example, there might be a change to the database that is made between version 2 and 3, but also between 3 and 4, in which case you need to handle people who will be jumping from 2 straight to 4, who do not update their APK files as often as you the developer might like!

    A simple way of doing this is using if statements, and updating the database in order, so processing upgrades chronologically.

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

Sidebar

Related Questions

I am developing an android application in which I have created a database named
I have a problem regarding Android App. I have created an application that download
My application have to load some points from internal sqlite database of android, and
I have a class which extends Application in an Android tabHost app. In the
I have created a database for my application. Now I want to make sure
I have created one application which contains several buttons to home page clicking on
I have an application which requires the use of SQLite (Android's database). I have
I am developing an android database application in which i have to add multiple
I have Created a database in Sqllite Android Application and I tried to add
I am developing an android application in which i have to show data from

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.