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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:53:45+00:00 2026-05-31T06:53:45+00:00

I have an iOS app that uses a SQLite DB to store its data

  • 0

I have an iOS app that uses a SQLite DB to store its data model. The user cannot change the contents of this DB in any way. The only way contents of the DB will change is when I add more content in future app updates. (The app never writes content to the DB, only reads from it)

So, when I perform such an update, I want it to use the “newer” version of the DB in the new version I am creating, and to just get rid of the old DB. What’s the best way to go about this? Is there a simple way to just tell it to grab the new version of the DB when I update, or do I need to program in custom logic for that?

  • 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-05-31T06:53:47+00:00Added an answer on May 31, 2026 at 6:53 am

    Let’s discuss from the beginning of your app been installed for the first time.
    The sqlite db will be init in the flowing steps:

    1. Check if the [appname].db exist in the app install folder.

    2. Create an empty [appname].db file in the install folder if this file does not exist.

    3. Create a record to indicate the current app version and store it in the table named ‘appversion'(this also can be stored in preference file).

    4. Load the old version number from the location where you store it in step 3,
      compare it to the current version number,and you need to execute serval sql files named like ‘[appname]_sql_v1.sql,[appname]_sql_v2.sql,[appname]_sql_v3.sql’,Keep in mind that ,each edition will own a ‘[appname]_sql_v*.sql’ file that contains all the table schema changes and records changes.if your app have been upgrade to version 7,you will find 7 sql files in you app package.

    5. Let’s assume that some guy have installed a app versioned 2,but did not update until one day he/she find the current version is 7,and then he/she upgrade it to 7. Two code version number will be loaded when he/she started the app for the first time after the upgrade finished:2 and 7,so these sql files:[appname]_sql_v3.sql,[appname]_sql_v4.sql,[appname]_sql_v5.sql,[appname]_sql_v6.sql,[appname]_sql_v7.sql will be execute one by one.

    Remember these things:

    1.do not put sql init statement in code,put it in a sql file and read it to sqlite db
    as needed.

    2.Each edition will owns a ‘[appname]_sql_v*.sql’ file that contains the changes made to the pervious version.

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

Sidebar

Related Questions

I have an app for iOS that uses Filesharing to provide the user with
I have an iOS app that stores some data in a sqlite database. The
I have developed an iOS app that uses CoreData/SQLite. It works, but now I
I have an iOS app that displays content from a sqlite db in a
I have an iOS (4.0) app that I would like to change the alpha
I am creating an iOS app that reads data from a single SQLITE table
I have an iOS app that connects to a server periodically looking for data
Using iOS 4.3 on an ipad app I have a custom NSOperation that uses
I'm working on an iOS app that uses an NSTimer for a countdown. This
I have an app that uses several different user defaults that need to be

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.