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

  • Home
  • SEARCH
  • 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 1042809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:34:02+00:00 2026-05-16T15:34:02+00:00

I have an app that uses a database. At startup I check to see

  • 0

I have an app that uses a database. At startup I check to see if my tables are missing and if so I create them. Works great.
I’ve noticed that if I “adb uninstall” then the next time I run my app the tables are created again (this is what I need), but what about when updating through the marketplace?
I’m in the process of releasing an update, and I’ve made major changes to the tables. I’d like it if the tables were completely wiped and re-created, in fact my app needs this to happen. If someone updates and has the old tables then there will be a force close.
Does anyone know the specifics of this scenario?

My tables are only for lookup, I store no user data so I dont really care about losing data on the updates.
Of course I know an option is to use some type of “version” table and check to see if I need to manually drop and create, but I was wondering if that was even needed.
Thanks.

  • 1 1 Answer
  • 1 View
  • 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-16T15:34:03+00:00Added an answer on May 16, 2026 at 3:34 pm

    On an update the tables are left alone. I’m going to assume you have implemented a subclass of SQLiteOpenHelper to explain this. The way Android is able to handle version changes is through the use of onUpgrade in the SQLiteOpenHelper class. This method is called from SQLiteOpenHelpers constructor if the DB version is older than the version the app expects. From inside onUpgrade is where you are going to drop your old tables and create the new ones.

    onUpgrade (SQLiteDatabase db, int oldVersion, int newVersion){
     Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
                        + newVersion + ", which will destroy all old data");
                //we can change this to perform different behaviors
                db.execSQL("DROP TABLE IF EXISTS "+MYDB.TABLE_NAME);
                onCreate(db);
    }
    

    It is important to note the way Android tells if you are using a new DB version.

    DatabaseHelper(Context context) {
                super(context, DATABASE_NAME, null, DATABASE_VERSION);
            }
    

    That field DATABASE_VERSION is used, so you should use a final static int member as part of your DB implementation.

    Hope that helps, leave me a comment if you have questions.

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

Sidebar

Related Questions

A have an app with that uses an SQL database. The application is already
I have an app that uses LINQ to SQL to connect to database. I
I have an ASP.NET app that uses a SQL Server database. I now need
I have a standard php app that uses SQL Server as the back-end database.
I have an app that uses a SQLite database. When the app updates at
I have a Mango WP7.5 app that uses a local SqlCe database. I would
I have a standard Rails app that uses a database, sqlite3 and the webrick
I have a django app that uses MySQL as the database backend. It's been
I created a web app that uses a MySQL database, but I have to
I'm coding an app that uses an existing database, that database has some tables

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.