我应该将sqlite数据库文件写入Documents目录或Library / Caches吗? [英] Should i write sqlite database file to Documents directory or Library/Caches?

查看:146
本文介绍了我应该将sqlite数据库文件写入Documents目录或Library / Caches吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了Apple的数据存储指南,我真的很困惑,我应该保留我在我的应用程序中创建的sqlite数据库文件。即使应用程序处于Offfline模式,我也希望从sqlite文件中读取。我读到创建的这些文件应保存在Library / caches中,并设置不备份标志。请建议我采用相同的方法。

I have read the Data Storage guidelines of Apple and am really confused as to where i should keep the sqlite database files i am creating in my app. I want to read from the sqlite files even when the app is in Offfline mode. I read that such files created should be kept in the Library/caches with the "do not backup" flag set. Please suggest me the right approach for doing the same.

推荐答案

答案取决于数据库文件的创建方式:

The answer depends on how your database files are created:

根据数据存储指南页面



  1. 只有用户生成或不能生成的文档和其他数据否则应由您的应用程序重新创建,应存储在/ Documents目录的
    中,并且将自动由iCloud备份

  1. Only documents and other data that is user-generated, or that cannot otherwise be recreated by your application, should be stored in the /Documents directory and will be automatically backed up by iCloud.

可以再次下载或重新生成的数据应存储在/ Library / Caches目录中。您应该放入Caches目录的文件
的示例包括数据库缓存文件
和可下载内容,例如杂志,报纸,
和地图应用程序使用的文件。

Data that can be downloaded again or regenerated should be stored in the /Library/Caches directory. Examples of files you should put in the Caches directory include database cache files and downloadable content, such as that used by magazine, newspaper, and map applications.


这对我来说似乎相对清楚:如果您的应用程序以编程方式创建或生成您想要保存的数据,请将其放入它在Caches文件夹中。如果它是客户自己生成的独特内容(通过键入键盘或他们手动干预的内容),请将其放入文档中。

This seems relatively clear to me: if your app programatically creates something or generates data that you want saved, put it in the "Caches" folder. If it's something unique that the customer themselves generate (via typing into a keyboard or something they manually intervened and did), put it in "Documents".

不备份意味着文件从不被发送到iCloud,如果它们丢失,则必须从头开始重新创建(或重新安装)。

"Do Not Backup" means that the files never get sent up to iCloud and if they get lost, they have to be re-created from scratch (or re-install).

这篇关于我应该将sqlite数据库文件写入Documents目录或Library / Caches吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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