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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:57:51+00:00 2026-06-13T14:57:51+00:00

I created an Android application which, check at startup if there is a new

  • 0

I created an Android application which, check at startup if there is a new version of application. If yes, the application download the new apk file and over-install new apk.
My application use the sqlite db. But this db, from one version to other can change.
I think I have to use the method:

 onUpgrade()

but I don’t know exactly how to use it.

When I start the application I use this code for crete database(if not exists):

DbHelper mDHelper = new DbHelper(context, DB_NAME, null, DB_VERSION)

What should I change if I want use onUpgrade() method?
And when do I have to call it?

  • 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-13T14:57:52+00:00Added an answer on June 13, 2026 at 2:57 pm

    onUpgrade() is called (you do not call it yourself) when version of your DB changed which means underlying table structure changed etc.

    In general it means that OS is telling you “hey, you asked for database structure version 10 but I found we got something older here, so this is you chance to fix that before you start using database (and potentially crash due to structure mismatch)”.

    In that method you should do all that is necessary to, well.. upgrade structure of your old database to structure matching current version requirements like adding/droping columns, converting row contents or even dropping old db completely and create it from scratch – for Android it does not matter what you do here – it’s just a sort of emergency callback for your code to do the necessary job (if any). You need to be aware that users may not update frequently so you have to always handle upgrade from version X to Y knowing that X may not be equal to i.e. (Y-1).

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

Sidebar

Related Questions

Created BroadcastReceiver which displays application name and version number on install/ uninstall of any
I have a problem regarding Android App. I have created an application that download
I created an application which is currently on Android market. The key used to
I am developing an android application in which i have created five tabs and
I need to work with REST api in android application which is created by
I am new to Android. I am trying to develop an Alarm Application, which
In my android application i have created the database which contains some data and
I've created an Android application which has a certain package name that I've been
I'm working on an android application which allows users to create accounts on a
I have created an android application that calls (using kSOAP library) a SOAP based

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.