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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:08:38+00:00 2026-06-09T15:08:38+00:00

I made a Core Data application, and I want to save the file.sqlite to

  • 0

I made a Core Data application, and I want to save the file.sqlite to a different directory from the default. I came across this SO thread, then posted this SO question, and the project appears to be compling, but my the file.sqlite is not getting saved in the location I specified. I created a method, and added some code to the AppDelegate.m file, but the storeURL variable is still saving the file.sqlite in the default “Documents directory. How do I call the method I created within the AppDelegate.m file to specify the proper location for the storeURL variable?

Should I just change,

NSURL *storeURL = [NSURL fileURLWithPath: [docPath stringByAppendingPathComponent:@"Accounts.sqlite"]];

to

NSURL *storeURL = [NSURL fileURLWithPath: [documentsDirectoryPath stringByAppendingPathComponent:@"Accounts.sqlite"]];

Also will this break iOS Simulator support?

  • 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-09T15:08:39+00:00Added an answer on June 9, 2026 at 3:08 pm

    I solved this problem by keeping the default documents path for the simulator, and then setting up a different documents path for the device. The following code is in my AppDelegate.m file

    // add conditional code for simulator and iDevice
    #if TARGET_IPHONE_SIMULATOR
    NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    
    NSString *docPath = [documentPaths objectAtIndex:0];
    
    NSURL *storeURL = [NSURL fileURLWithPath: [docPath stringByAppendingPathComponent:@"Accounts.sqlite"]];
    #else
    // jailbroken path - /var/mobile/Library/KegCop/
    NSString *docPath = self.documentsDirectoryPath;
    
    NSURL *storeURL = [NSURL fileURLWithPath: [docPath stringByAppendingPathComponent:@"Accounts.sqlite"]];
    #endif
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CoreData-based application that retrieves data about past events from an SQLite
My application downloads posts from a server and stores them in Core Data. Since
I made an application that passes trough an XML file and extracts the entries
I have made an application project in Visual Studio 2008 C#, SQL Server from
Environment: xcode 3.2.1, document-based core-data application. I have a document-based cocoa app which uses
An iPhone app which I am creating generates reports from a Core Data database
I have an application that pulls data from the web, parses them, and compiles
I made a simple Core Data Example: NSLog(@Loading...); NSURL *modelUrl = [[NSBundle mainBundle] URLForResource:@CoreDataTest
I have a document-based Core Data application (running on Mac OS X 10.5 and
I have developed a application that using core data framework to store the data.

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.