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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:25:06+00:00 2026-06-18T05:25:06+00:00

My IOS5, Iphone app uses a database, which I populate with data outside the

  • 0

My IOS5, Iphone app uses a database, which I populate with data outside the app.

The app only opens the database file and reads the data, no insertion or updates.

App works fine in the simulator, but when I publish it to the iphone it crashes – I believe it is because database file wasn’t copied.

Currently file is on

/Users/stenio123/Library/Application Support/iPhone Simulator/6.0/Applications/4B3205EB-D98B-4D65-B22A-57E5E6A93F3C/MyAppName.app/MyDatabase.data

I I get the location path in the code by using

NSArray *documentDirectories = 
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                        NSUserDomainMask, YES);     
NSString *documentDirectory = [documentDirectories objectAtIndex:0];
documentDirectory stringByAppendingPathComponent:@"MyDatabase.data"]

Which works on the simulator.

However what should I change so that it works on the real iPhone?

I tried dragging and dropping the MyDatabase.data file to XCode, making sure I checked “Copy items” and “add to target”. Then I changed the code above to the following variations

NSString *documentDirectory = @"/MyDatabaseFolder/";

NSString *documentDirectory = @"./MyDatabaseFolder/";

NSString *documentDirectory = @"MyDatabaseFolder/";

But none worked, not even in the simulator. Could you please advise?

  • 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-18T05:25:08+00:00Added an answer on June 18, 2026 at 5:25 am

    Try add your database file to the application’s bundle by dragging it into your project, in Xcode, instead of just adding it to the document directory. From there, you can use it at will and it should be copied to the device. For example:

    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"MyDatabase" ofType:@"data"];  
    NSData *data = [NSData dataWithContentsOfFile:filePath];  
    if (data) {
    
        // do something with the database data
    
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an iphone app which is only in portrait orientation,even though i
My app uses an sqlite database managed with core-data. These are the errors I
This question is in reference to an iPhone app which uses Xcode's Master Detail
In an iPhone app for iOS5 I'm trying to create a controller object that
I have an app which requires a Facebook login. The logic call uses forge.facebook.authorize(
I am developing a iPhone app running on iOS5, and am unable to set
I am developing an app for iPhone using iOS5 and xcode 4.2. The scenario
Im building an iphone app through xcode and objective c. building for ios5.0 min
I have developed iPhone app which contains a 80MB audio files and 20MB images
I have existing iphone app which is developed using XCode 4.2 and base sdk

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.