需要澄清我应该放置(存储)我的核心数据的SQLite文件的位置? [英] Clarification needed about Where I Should Put (Store) My Core Data’s SQLite File?

查看:135
本文介绍了需要澄清我应该放置(存储)我的核心数据的SQLite文件的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,我知道。 存储核心数据文件的位置已经回覆了此问题。将coredata文件存储在文档目录之外?



@Kendall Helmstetter Gelner和@Matthias Bauch提供了非常好的回复。我很高兴他们。



现在我的问题很概念,我会尝试解释一下。



你应该把你的应用程序的文件部分在Apple文档中,我已经阅读了以下内容:


处理支持文件 - 您的应用程序下载或生成的文件,
可以根据需要重新创建 - 以下两种方式之一:




  • 在iOS 5.0及更早版本中,将支持文件放在/ Library / Caches目录中,以防止它们被备份


  • 在iOS 5.0.1及更高版本中,将支持文件放在/ Library / Application Support目录中,并应用
    com.apple.MobileBackup 扩展属性给他们。此属性
    可防止将文件备份到iTunes或iCloud。如果
    有大量的支持文件,您可以将它们存储在自定义
    子目录中,并将扩展属性应用于目录。



Apple表示,为了处理支持文件,您可以根据安装的iOS进行两种不同的方式。在我看来(可能我错了),一个核心数据文件是一个支持文件,因此属于这些类别。



说这个,Matthias的做法肯德尔还是继续有效吗?特别是,如果我在文件夹中创建一个目录,例如私人,这个目录在iOS 5版本(5.0和5.0.1)中继续保持隐藏,还是需要跟随Apple解决方案?如果后者有效,可以提供任何样品或链接吗?



提前谢谢。

解决方案

我会说Core Data文件不是一个真正的支持文件 - 除非你有一些方法来复制存储的数据,那么你需要备份。



支持文件是更多的东西,如图像或数据库,只是远程网站的缓存。



所以,你可以继续将您的Core Data数据库放置在您喜欢的位置(尽管应该在应用程序支持下)。



截至2013年1月的最近添加:Apple已经开始处理预加载的CoreData数据存储您将一个捆绑包复制到可写入区域,就像它们是一个支持文件 - 即使您将用户数据写入相同的数据库也是如此。解决方案(来自DTS)是确保将数据库复制到位时,设置不备份标志,然后取消设置,如果用户数据写入数据库。



如果您的CoreData存储纯粹是下载的网络数据的缓存,请继续确保它像缓存中的某个地方,或者设置了不备份标志。


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.

解决方案

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.

这篇关于需要澄清我应该放置(存储)我的核心数据的SQLite文件的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆