Scrungepipes
Scrungepipes

Reputation: 37581

Where is the name/location of the core data file?

I'm just getting started learning CoreData for iOS and have written some exploratory code to store (via ManagedObjectContext save) and read data successfully.

However I've got lots of data in the file but want to start out again from scratch, so figured I'd just delete it manually in the file system. But what's its name/location? I can't see anything that looks like it by manually browsing around, and while I've not finished reading my book on core data yet, flicking through it I can't find any reference to this sort of information.

TIA

Upvotes: 1

Views: 6355

Answers (3)

Ryan Dines
Ryan Dines

Reputation: 1037

Deleting simulator data for dummies:

  1. Open finder
  2. Open Utilities
  3. Open terminal
  4. Make sure simulator is not open
  5. Type this in terminal: xcrun simctl erase all

Upvotes: 0

Matthias Bauch
Matthias Bauch

Reputation: 90117

The file is in the application directory of your iPhone simulator e.g. /Users/matthias/Library/Application Support/iPhone Simulator/5.0/Applications/EB33C087-A250-483E-96DD-D265ED3F0985/Documents/Foobar.sqlite

Just put a NSLog in the persistentStoreCoordinator getter to see the exact location.

Like this:

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
    /* ... */    
    NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"Foobar.sqlite"];
    NSLog(@"CoreData Location: %@", storeURL);

Upvotes: 7

jamapag
jamapag

Reputation: 9318

You can remove your application from simulator or your iPhone/iPad/iPod and install it again. CoreData database will be cleared.

Upvotes: 3

Related Questions