title: Where to store private important user data when the Documents directory is not an option?
body: <p>My app is using iTunes file sharing which exposes everything in the Documents directory to the user, making it vulnerable to accidentally deletion or manipulation.</p>
  
  <p>I spent hours in reading though these documents but it is a mess and I hope someone knows from experience. First, in one place they say that I should put these files in the <strong>Library</strong> directory.</p>
  
  <p><a href="http://developer.apple.com/library/ios/#qa/qa1699/_index.html" rel="noreferrer">In this technical Q &amp; A</a> Apple says that this is preserved. From my understanding this means that I can safely put important user data like sqlite3 database files in this directory. When the user updates to a new version, the content inside this directory will be preserved, it will survive and be available after the update:</p>
  
  <blockquote>
    <p>applications can create their own
    directories in
    /Library/ and those
    directories will be preserved in
    backups and across updates</p>
  </blockquote>
  
  <p><strong>So /Library/ is preserved in backups and across updates.</strong></p>
  
  <p>For me with bad english this means: YES, the data will survive. It will not be lost when the user backs up. It will not be lost when the user updates. I looked up the word "preserved" in several dictionaries and I am sure it means "it will survive".</p>
  
  <p>But then, there is <a href="http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/RuntimeEnvironment/RuntimeEnvironment.html#//apple_ref/doc/uid/TP40007072-CH2-SW10" rel="noreferrer">this note in the iOS Application Programming Guide</a> which tells something completely different! Here, they say about the Library directory:</p>
  
  <blockquote>
  <pre><code>&lt;Application_Home&gt;/Library/
  You should not use this directory for user data files.
  The contents of this directory (with the exception of the Caches
  subdirectory) are backed up by iTunes.
  Your application is generally
  responsible for adding and removing
  these files. It should also be able to
  re-create these files as needed
  because iTunes removes them during a
  full restoration of the device.
  </code></pre>
  </blockquote>
  
  <p><strong>"Should not use for user data files." (???)</strong></p>
  
  <p>But at the same time they admit it's backed up by iTunes. OK. So why shouldn't I put user data files into there, then?</p>
  
  <blockquote>
    <p>/Library/Caches
    Use this directory to write any application-specific support files
    that you want to persist between
    launches of the application or during
    application updates. (...)
    It should also be able to re-create
    these files as needed because iTunes
    removes them during a full restoration
    of the device.</p>
  </blockquote>
  
  <p>What?! I should put these files in Library/Caches. But this directory <strong>is not backed up by iTunes</strong>, as they said above. So this is only save for updates, but not for backup. And the data might be deleted anytime by the system.</p>
  
  <p>Now this is completely confusing me. From what I understand I can choose between the evil and the devil: Data in /Library/ does not survive updates but is backed up by iTunes. Data in /Library/Caches does survive updates, but is not backed up by iTunes AND it might be deleted by the system (since it's a "Cache") anytime.</p>
  
  <p>And on the other hand, the technical Q &amp; A suggests putting this important user data in a custom subfolder in /Library/, for example /Library/PrivateDocuments.</p>
  
  <p>In contrast to the iOS Application Programming Guide, the technical Q &amp; A says: <strong>the entire /Library directory has always been preserved during updates and backups</strong></p>
  
  <p>So now, really, one of both documents MUST be wrong. But which one? What's the truth? Please, not speculation! I'm looking for answers from experience and I feel there is no way to figure this out except releasing an app and praying. Maybe someone wants to share his/her experience what really worked.</p>