gpt4 book ai didi

iphone - 我应该将 sqlite 数据库文件写入文档目录还是库/缓存吗?

转载 作者:行者123 更新时间:2023-12-03 18:56:30 27 4
gpt4 key购买 nike

我已经阅读了 Apple 的数据存储指南,并且对于应该将我在应用程序中创建的 sqlite 数据库文件保存在哪里感到非常困惑。即使应用程序处于离线模式,我也想读取 sqlite 文件。我读到创建的此类文件应该保存在库/缓存中,并设置“不备份”标志。请建议我执行相同操作的正确方法。

最佳答案

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

According to the Data Storage Guidelines page :

  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.

  2. 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.

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

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

关于iphone - 我应该将 sqlite 数据库文件写入文档目录还是库/缓存吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11840318/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com