我有一些简单的疑问。我有一个在 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/