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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:14:55+00:00 2026-05-23T15:14:55+00:00

i was wondering why we search a path with NSDocumentDirectory at first here :

  • 0

i was wondering why we search a path with NSDocumentDirectory at first here :

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);  
NSString *documentsDirectory = [paths objectAtIndex:0];  
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"Sports.sqlite"];

and later on we compare this path with another path, using this time resourcePath from the NSBundle :

NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] 
                                        stringByAppendingPathComponent:@"Sports.sqlite"];  
success = [fileManager copyItemAtPath:defaultDBPath
                               toPath:writableDBPath error:&error];

What is the difference between both?

  • 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-23T15:14:56+00:00Added an answer on May 23, 2026 at 3:14 pm

    In this situation you are (normally one time only, unless you need to restore database) copying the database from your read only bundle into your documents directory so that a user can read/write to it. This is useful if you want to pre-seed a database or just have the structure set up.

    Your documents directory is read/write and your bundle is not therefore you need to have the sqlite in your documents directory for it to be used properly.

    1. The first part of code is simply getting you the path for where you want the sqlite file to live in your documents directory. Which ends up being held in writableDBPath.

    2. Next you get the path from your bundle (defaultDBPath) and use the two paths to

      ... copyItemAtPath:defaultDBPath toPath:writableDBPath ...
      

    This gives you a read/write database that you provide in your bundle. Why would you do this instead of running your SQL on the device to create the schema? This allows you to pre-seed the database with some data. It can sometimes be easier to use a graphical tool to set up and edit your sqlite file

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

Sidebar

Related Questions

Possible Duplicate: How can I search a graph for a path? I was wondering
I've had a little search and I was wondering if there is back compatibility
Im creating a minesweeper and just wondering what is the best algorithm to search
was wondering how to do a search result using PHP + MySQL but not
Just wondering if there is any tips on improving search times (full-text). How do
I am really wondering if i can use search for a HTML website. The
Im working on a multilingual site using asp.net mvc, and im wondering how search
just wondering if i can search for places near to a specific lat/lang with
I was wondering how I would search more tables in my search database to
Simply wondering if any SEO specialists out there know if Google or other search

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.