1

In my application's documents folder, I do not find my SQLite database

Library/Application Support/iPhone Simulator/6.1/"random app id"/Documents/

^This folder is empty

MagicalRecord seems to be working, I just have no idea how to find the database.

I use the following to set up Magical Record

[MagicalRecord setupAutoMigratingCoreDataStack];

So where does MagicalRecord store its database?

GangstaGraham
  • 8,865
  • 12
  • 42
  • 60

4 Answers4

4

MagicalRecord stores, by default, all data stores in the following location:

{App Folder}/Library/Application Support/{App Name from Info.plist}/{storeName.sqlite}

This is easily accessible from the simulator as well as documents.

casademora
  • 67,775
  • 17
  • 69
  • 78
  • 1
    I only have three files in this location instead of sqlite; AppName AppName-shm AppName-wal – GangstaGraham May 07 '13 at 21:29
  • @GangstaGraham The wal file is the SQLite write ahead log, and the shm is the SQLite shared memory file. The "AppName" file is most likely your SQLite database. – rickerbh May 08 '13 at 00:26
  • I figured out that in the Store Named string I inputted "AppName" instead of "AppName.sqlite", I just thought it would add in the sqlite by itself, anyways thank you SO SO much, the database really helps in understanding what the program is doing, so it's great to be able to access it again. Thanks a lot! @rickerbh – GangstaGraham May 08 '13 at 00:53
  • Any reason of why you put in /Application Support/ instead /Caches/ ? – Maystro May 15 '15 at 22:55
3

You can log your SQlite file location using the following NSPersistentStore MR addition :

[NSPersistentStore MR_urlForStoreName:[MagicalRecord defaultStoreName]]
Thomas Desert
  • 1,346
  • 3
  • 13
  • 28
0

If you know the name of the sqlite file then just do a search in OSX for that file to find the directory. Otherwise the file was never created.

Make sure you are setting up the CoreData stack correctly as per the documents.

+ (void) setupCoreDataStackWithAutoMigratingSqliteStoreNamed:(NSString *)storeName;
Mark McCorkle
  • 9,349
  • 2
  • 32
  • 42
0

Swift + Xcode 7 + simulator 9.0

Please go to your AppDelegate.swift

change

MagicalRecord.setupCoreDataStackWithStoreNamed("yourDBName.sqlite")

to

MagicalRecord.setupCoreDataStackWithAutoMigratingSqliteStoreNamed("yourDBName.sqlite")

Now you can locate the yourDBName.sqlite at /Users/userName/Library/Developer/CoreSimulator/Devices/"random app id"/data/Containers/Data/Application/"random app id"/Library/Application Support/ProjectName

There is a useful tool: simPHolders2 (http://simpholders.com) simPHolders easy to access all application folders

Sen-He Lee
  • 134
  • 1
  • 13