Where should I store the SQLite DB for my iPhone app? Where should I store the SQLite DB for my iPhone app? database database

Where should I store the SQLite DB for my iPhone app?


Apple's file system programming guide for iOS describes the (application_home)/Library path as a place to "create custom subdirectories for files you want backed up but not exposed to the user". The (application_home)/Documents path is described as "the contents of this directory can be made available to the user through file sharing."

Your databases don't sound like documents, they sound like private caches that users shouldn't know about. I recommend you create a directory such as (application_home)/Library/Database and save files there. The cache path you mention doesn't sound like the best option to me.

You should really review the entire file system programming guide for iOS before submitting another app.


6 year update:

Storing the data in the NSCachesDirectory caused a bug, as expected, that the users customized data would erase whenever the device felt like it. After many many attempts at arguing the point with Apple app review, I was able to finally post an update where the data is now stored in a custom directory in the NSDocumentsDirectory (as it should be) which solved all of the aforementioned issues.


If your database indeed contains user-generated content, then the Documents directory is its proper location.

However, you mention that you are persisting "your users settings"... If the data you are persisting are more akin to settings or preferences, then they should reside in the Defaults subsystem. See the documentation for NSUserDefaults.