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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:36:20+00:00 2026-06-14T11:36:20+00:00

I have an app I need to update with new data for the DB.

  • 0

I have an app I need to update with new data for the DB. There’s nothing else there to update, no schema changes, no code changes. All I want to do is add some rows to a DB that the user can’t modify.

Normally on first install, I copy the DB from assets/. After that, when the program runs, I check whether the DB file exists in /data/data/my.package/databases and if it does, I don’t copy a second time.

Now, the new version of the app will have the full DB intact, and I want to add the new rows for those who have the old version. I have a few options:

  • Use the onUpgrade() function of SQLiteOpenHelper to insert the rows. I don’t want to do this because there are many rows, and I’d rather put them in the assets/ folder to be imported. Is there a way to access assets/ from within onUpgrade()?
  • Delete and recreate the DB on every launch. This is wasteful, but it ensures that the full DB is there no matter what previous version of the app was installed.
  • Do a check to see the previous version of the app that was installed and selectively delete the DB at first launch to have the DB with new rows copied from assets/ only on the first launch. For this, I can’t quite figure out what I should check. There is no way to know the old app version when running. I thought of using PackageInfo.firstInstallTime or PackageInfo.lastUpdateTime and checking for a time where, if the user installed/updated before that, then they obviously have the first version I’m looking for. I know that’s error-prone, but I’ve taken the app off the market right now, so I have some leeway here.

An alternative way of phrasing this questions is: If I’m upgrading an app and I have some files in /data/data/my.package/* that I either want to delete or update, based on the version change, how can I accomplish that since I can’t know what previous version was installed?

  • 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-14T11:36:22+00:00Added an answer on June 14, 2026 at 11:36 am

    The onUpgrade callback tells you both the old and new versions.

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

Sidebar

Related Questions

I have an app that I need to get the source code to update
I have Core Data setup in my app and need to fetch a bunch
I have some data, and I update it in a task: The app is
I have newer version app to update to app store, but since there were
I have an app where I need to get the list of countries,languages etc
I have an app where I need a BOOL value to persist across launches.
I have an app which generates some files in the app directories I need
In my app I have need to trigger show some custom view when status
I have created a Mac app and need to place a shadow behind the
I have a VB app that I need to monitor while it is running.

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.