更新应用程序后保留数据 [英] Retaining data after updating application

查看:146
本文介绍了更新应用程序后保留数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些简单的疑问。我有一个在sqlite中存储一些重要数据的应用程序。更新应用程序后,我保存在数据库中的数据是否会被删除?我的意思是当新版本发布并安装在iPhone中时。如果将其删除,我该如何保留在所有版本上持久的数据。

I have some simple doubts. I have an application that store some important data in sqlite. Does the data I have kept in a Database would be removed after updating the application. I mean when a new version released and installed in iPhone. If it will remove, how can I keep data that persistant over all versions. Thanks in advance.

推荐答案

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

As long as the database file is kept in the applications documents directory it will not be overwritten on application update. However, if the schema changes you will need to migrate your data from the previous data store to a new one and then move it into place.

来自iOS编程指南:

From the iOS Programming Guide:


在应用程序更新期间保存的文件

Files Saved During App Updates

当用户下载应用程序更新时, iTunes将更新安装在新的应用程序目录中。然后,它将用户的数据文件从旧的安装移到新的应用程序目录,然后再删除旧的安装。

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.

此文档

这篇关于更新应用程序后保留数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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