iphone - 更新应用程序后保留数据

标签 iphone objective-c cocoa-touch

我有一些简单的疑问。我有一个在 sqlite 中存储一些重要数据的应用程序。更新应用程序后,我保存在数据库中的数据是否会被删除。我的意思是当新版本发布并安装在 iPhone 中时。如果它会被删除,我怎样才能保持数据在所有版本上持久存在。提前致谢。

最佳答案

只要数据库文件保存在应用程序文档目录中,它就不会在应用程序更新时被覆盖。但是,如果架构发生更改,您将需要将数据从以前的数据存储迁移到新的数据存储,然后将其移动到位。

来自 iOS 编程指南:

Files Saved During App Updates

When a user downloads an app update, iTunes installs the update in a new app directory. It then moves the user’s data files from the old installation over to the new app directory before deleting the old installation.

Files in the following directories are guaranteed to be preserved during the update process:

  • Application_Home/Documents
  • Application_Home/Library

Although files in other user directories may also be moved over, you should not rely on them being present after an update.

发现于this document .

关于iphone - 更新应用程序后保留数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9107148/

相关文章:

iphone - NSFetchedResultsControllerDelegate 未触发

iphone - 在 UILongPressGestureRecognizer 持续时间内执行操作

iphone - iPhone 的反向查找 API?

iphone - 为 iPhone 中录制的音频实现噪声过滤算法

IOS - 请求成员 'domain' 不是结构或联合?

php - 新手-创建可以存储图片并返回url的服务器-iOS

iphone - 无法将应用提交到App Store,无法选择任何应用

objective-c - AnyObject 到 NsDictionery

iphone - UIView:如何确定一个 View 是否已经存在?

ios - 比较 UIImage