2

Yes, I know. This question have been already replied in Where to store the Core Data file? and in Store coredata file outside of documents directory?.

@Kendall Helmstetter Gelner and @Matthias Bauch provided very good replies. I upvoted for them.

Now my question is quite conceptual and I'll try to explain it.

From Where You Should Put Your App’s Files section in Apple doc, I've read the following:

Handle support files — files your application downloads or generates and can recreate as needed — in one of two ways:

  • In iOS 5.0 and earlier, put support files in the /Library/Caches directory to prevent them from being backed up

  • In iOS 5.0.1 and later, put support files in the /Library/Application Support directory and apply the com.apple.MobileBackup extended attribute to them. This attribute prevents the files from being backed up to iTunes or iCloud. If you have a large number of support files, you may store them in a custom subdirectory and apply the extended attribute to just the directory.

Apple says that for handling support files you can follow two different ways based on the installed iOS. In my opinion (but maybe I'm wrong) a Core Data file is a support file and so it falls in these categories.

Said this, does the approach by Matthias and Kendall continue to be valid or not? In particular, if I create a directory, say Private, within the Library folder, does this directory continue to remain hidden both in iOS 5 version (5.0 and 5.0.1) or do I need to follow Apple solution? If the latter is valid, could you provide any sample or link?

Thank you in advance.

Community
  • 1
  • 1
Lorenzo B
  • 33,216
  • 24
  • 116
  • 190

1 Answers1

1

I would say that a Core Data file is not really a support file - unless you have some way to replicate the data stored, then you would want it backed up.

The support files are more things like images, or databases that are only caches for a remote web site.

So, you could continue to place your Core Data databases where you like (though it should be under Application Support).

Recent addition as of Jan 2013: Apple has started treating pre-loaded CoreData data stores that you copy from a bundle into a writable area, as if they were a support file - even if you write user data into the same databases also. The solution (from DTS) is to make sure when you copy the databases into place, set the do-not-backup flag, and then un-set that if user data is written into the database.

If your CoreData store is purely a cache of downloaded network data, continue to make sure it goes someplace like Caches or has the Do Not Backup flag set.

Kendall Helmstetter Gelner
  • 74,769
  • 26
  • 128
  • 150
  • + 1 for your support. So, to prevent user to see that file, do I have to put it under Application Support or under Library? What directory will you prefer? Thank you very much. – Lorenzo B Sep 13 '12 at 07:30
  • Furthermore, do you mean Application Support under /Library/ folder (the second item in the list above)? Thanks. – Lorenzo B Sep 13 '12 at 10:08
  • 1
    There is no-where you can hide the file if they want to find it, as with a tool like iPhone explorer you can browse the entire application sandbox. Yes, I did mean the Application Support under Library... – Kendall Helmstetter Gelner Sep 13 '12 at 11:47