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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:29:53+00:00 2026-06-04T09:29:53+00:00

I am working with updation of database in a project in which the database

  • 0

I am working with updation of database in a project in which the database found in mainBundle needs to be updated. as we already know that files in mainbundle are read only i copied the database in the mainBundle to the document directory for updation . After updation i want to replace that file in document directory to the file in mainBundle.
Can anyone please tell me how to solve this issue.
Thanks in advance

  • 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-04T09:29:54+00:00Added an answer on June 4, 2026 at 9:29 am

    That can not be done. As you cannot update any of your bundle file. Somehow if you do that your build will show a invalid binary message on next run.

    By the way why you need to update the DB from your main bundle? Your mainbundle database file is a copy of your original database and that should be copied in document directory for modifying it.

    UPDATE

    For the case you want to persist your record even after restarting the app thats why we use database. For solving your issue do follwoing:

    NSString *docDirPath = [(NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)) objectAtIndex:0];
    

    This will return path for your document directory. After that copy your database to this path as follows:

    NSString *dbPath = [strDocPath stringByAppendingPathComponent:@"myDb.sqlite"];
    if (![[NSFileManager defaultManager] fileExistsAtPath:dbPath]) {
        [[NSFileManager defaultManager] copyItemAtPath:[[NSBundle mainBundle] pathForResource:@"mydb" ofType:@"sqlite"] toPath:dbPath error:nil];
    }
    

    This will check if database is already exist at path than it won’t replace it with empty database and if database is not exist (i.e your first run of app) it will copy.

    Now you can access dbPath for accessing database which is in you document directory and will be persistent even after restarting app.

    Don’t forgot to check your database existance with if (![[NSFileManager defaultManager] fileExistsAtPath:dbPath]) { otherwise your app will replace your document directory’s db with original (empty database) on every run.

    Hope this help.

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

Sidebar

Related Questions

Working on a website that has Employee and Branch entities, using a database table
Working on a project that parses a log of events, and then updates a
Working on a mobile app that needs to use a public API for accessing
Working on a legacy ASP.NET application we've found that ASP.NET session gets used for
Working on a bunch of forms at the moment and I'm finding that I
Working on a movie website and would love to find an API that I
Working on my first Rails project, I used Ryan Bates' Nifty-Generators to create the
Working on joining up two legacy DB systems into new database where I can
Working on calling a C function from my asm project. I'm trying to push
Working on an extension that use the new experimental devtools apis. How do you

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.