2019独角兽企业重金招聘Python工程师标准>>>

有这样一个问题,用户用iOS设备下载了大量的数据,保存在设备本地,如果用户升级了应用本身,这些文件是否仍然存在。

找了一些官方解释和Stackflow上的说明

Where You Should Put Your App’s Files

To prevent the syncing and backup processes on iOS devices from taking a long time, be selective about where you place files inside your app’s home directory. Apps that store large files can slow down the process of backing up to iTunes or iCloud. These apps can also consume a large amount of a user's available storage, which may encourage the user to delete the app or disable backup of that app's data to iCloud. With this in mind, you should store app data according to the following guidelines:

  • Put user data in the <Application_Home>/Documents/. User data is any data that cannot be recreated by your app, such as user documents and other user-generated content.

  • Handle support files—files your application downloads or generates and can recreate as needed—in one of two ways:

    • In iOS 5.0 and earlier, put support files in the <Application_Home>/Library/Caches directory to prevent them from being backed up

    • In iOS 5.0.1 and later, put support files in the <Application_Home>/Library/Application Support directory and apply thecom.apple.MobileBackup extended attribute to them. This attribute prevents the files from being backed up to iTunes or iCloud. If you have a large number of support files, you may store them in a custom subdirectory and apply the extended attribute to just the directory.

  • Put data cache files in the <Application_Home>/Library/Caches directory. Examples of files you should put in this directory include (but are not limited to) database cache files and downloadable content, such as that used by magazine, newspaper, and map apps. Your app should be able to gracefully handle situations where cached data is deleted by the system to free up disk space.

  • Put temporary data in the <Application_Home>/tmp directory. Temporary data comprises any data that you do not need to persist for an extended period of time. Remember to delete those files when you are done with them so that they do not continue to consume space on the user’s device.

也就是说,一般从网上下载的那些内容,包括杂志、报纸、视频什么的,都要放在 <Application_Home> /Library/Caches  目录下面

<Application_Home>/Library/

This directory is the top-level directory for files that are not user data files. You typically put files in one of several standard subdirectories but you can also create custom subdirectories for files you want backed up but not exposed to the user. You should not use this directory for user data files.

The contents of this directory (with the exception of the Caches subdirectory) are backed up by iTunes.

For additional information about the Library directory, see “The Library Directory Stores App-Specific Files.”

Library目录下面的内容,也会被被iTunes备份,但是Caches目录除外,也就是说这些网络下载内容文件放在这里是不会被备份的,

Caches

Use this directory to write any app-specific support files that your app can re-create easily. Your app is generally responsible for managing the contents of this directory and for adding and deleting files as needed.

In iOS 2.2 and later, the contents of this directory are not backed up by iTunes. In addition, iTunes removes files in this directory during a full restoration of the device.

On iOS 5.0 and later, the system may delete the Caches directory on rare occasions when the system is very low on disk space. This will never occur while an app is running. However, you should be aware that iTunes restore is not necessarily the only condition under which the Caches directory can be erased.

上面写的的比较清楚,Library/Caches目录下,一般情况下是不会被删除的,我理解,也包括stackoverflow网友的证明,应用升级的时候也不会被删除,实际上,应用升级的具体系统操作是这样的:

Files Saved During Application Updates When a user downloads an application update, iTunes installs the update in a new application directory. It then moves the user’s data files from the old installation over to the new application 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.

系统先新建一个应用目录,然后安装一个新版本应用,然后再把旧版本的应用数据拷贝过来,然后再删除旧版本的应用安装目录。

最后注意一下,Library/Caches目录下的数据虽然在一般情况下不会被删除,但是在系统恢复和其他一些罕见的情况下(比如非常底的磁盘空间条件下有可能)会被清除,所以你的程序每次都要检查一些,这些文件都还在不在了,不在的话只能重新下了。

Application_Home/Library/Caches Use this directory to write any application-specific support files that you want to persist between launches of the application or during application updates. Your application is generally responsible for adding and removing these files. It should also be able to re-create these files as needed because iTunes removes them during a full restoration of the device. In iOS 2.2 and later, the contents of this directory are not backed up by iTunes.

参考连接:http://stackoverflow.com/questions/7155964/will-application-home-library-caches-be-clear-on-app-update/7277797#7277797

File System Programming Guide

https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html#//apple_ref/doc/uid/TP40010672-CH2-SW1

转载于:https://my.oschina.net/u/1266799/blog/165631

iOS App 升级时文件的保留情况相关推荐

  1. ios app 版本更新上架发布

    打包app后发现由于客户证书过期导致app在App Store无法被搜索到,在更新版本时踩了一些坑. 一.如何申请ios证书 二.如何创建描述文件配置 三.ios上架流程 开发工具:apicloud ...

  2. iOS App与iTunes文件传输的方法和对iOS App文件结构的说明

    转:http://www.xiaoyaoli.com/?p=368 就像很多iOS上面的播放器App一样,本文编写一个程序可以通过iTunes往里面放文件,比如编写一个音乐播放器程序,通过itune往 ...

  3. iOS APP上架App Store其中一个步骤就是要把ipa文件上传到App Store

    下面进行步骤介绍! 利用Appuploader这个软件,可以在Windows.Linux或Mac系统中申请ios和上传IPA到App Store Connect. 非常的方便,没有Mac也可以用App ...

  4. 【苹果iMessage家庭推】 打开下载的证书文件,一样平常会主动用钥匙串访问程序打开的选择iOS App Development是开发证书

    推荐内容IMESSGAE相关 作者✈️@IMEAE推荐内容 iMessage苹果推软件 *** 点击即可查看作者要求内容信息 作者✈️@IMEAE推荐内容 1.家庭推内容 *** 点击即可查看作者要求 ...

  5. iOS App 崩溃报告符号化,.ips崩溃报告文件分析

    iOS App 崩溃报告符号化,.ips崩溃报告文件分析 2014-09-22, Mon | 评论 本文为翻译整理.来源: Symbolicating iPhone App Crash Reports ...

  6. [绍棠] iOS开发- 文件共享(利用iTunes导入文件, 并且显示已有文件) 以及 iOS App与iTunes文件传输的方法和对iOS App文件结构的说明

    就像很多iOS上面的播放器App一样,本文编写一个程序可以通过iTunes往里面放文件,比如编写一个视频播放器程序,通过itune往里面放视频文件,然后通过这个App来播放这个视频.下面是通过iTun ...

  7. ipa文件反编译_手把手教你反编译别人的iOS App

    下载智可网手机app可以学习更多哦! 虽然iOS系统相比于其他手机操作系统相对安全,但是这个安全并不是绝对的,我一直相信,道高一尺魔高一丈.此文想以实际例子出发,告诉大家,如何去反编译一个app,并且 ...

  8. C++ ifstream ofstream 用法解析(iostream、fstream头文件)(ios::app、ios::ate、ios::in、ios::out、ios::trunc)(未完)

    参考文章1:C++文件读写详解(ofstream,ifstream,fstream) 参考文章2:C++ 文件和流 文章目录 C++ 文件和流 打开文件 关闭文件 写入文件 读取文件 读取 & ...

  9. ios调用第三方程序打开文件,以及第三方调用自己的APP打开文件

    一.自己的APP调用第三方打开文件 主要是使用 UIDocumentInteractionController 类 并实现 UIDocumentInteractionControllerDelegat ...

最新文章

  1. l#039;oracle 酒,【金钟庄园副牌干红葡萄酒Carillon de L#039;angelus】价格_年份_评分 - 酒窝网官网...
  2. python set集合
  3. 微信小程序点击页面tab栏切换
  4. 【chainer速成】chainer图像分类从模型自定义到测试
  5. grunt之filerev、usemin
  6. CF429E Points and Segments(欧拉回路)
  7. C和汇编-----for循环
  8. 大数据2019年的三大趋势你看了吗?
  9. Python实例讲解 -- 发送邮件带附件 (亲测)
  10. JMeter——并发测试工具类安装及使用
  11. HDC.Cloud | 基于IoT Studio自助生成10万行代码的奥秘
  12. Servlet→对象监听器、事件监听器、Session钝化活化、@WebListener标注、过滤器概念原理生命周期、过滤器链、@WebFilter标注、定时器Timer、cancel()、purge
  13. 《我也能做CTO之程序员职业规划》之七:大学生职业规划技巧
  14. Windows 平台下Git 服务器搭建
  15. 参与全国软考调查问卷,赢精彩大奖
  16. 题解【NOIP2013_火柴排序】— 问题与转化
  17. DirectX诊断工具怎么打开?怎么查看当前电脑所支持的DirectX版本?
  18. html中让图片放大的代码,HTML5图片预览 放大(示例代码)
  19. 5G消息RCS富媒体通信与传统短信相比有何特色?
  20. web大作业介绍自己的家乡_中国10大乡村名鸭!快来看看自己家乡的鸭子是否上榜...

热门文章

  1. 了解Android Matrix转换
  2. centos7编译PGSQL9.6并配置UUID
  3. 使用Java 8 Optional避免空指针异常
  4. rac安装grid报INS-41112错误
  5. 使用ffmpeg推流到Wowza
  6. Unicorn 4.6.3 发布,Rack的HTTP服务器
  7. Struts2中action获取request、response、session的方式
  8. 终于要揭开神秘面纱?Magic Leap将要展示产品
  9. 数梦工场联手阿里云 推出大数据一体机
  10. 数据结构与算法 第二次实验报告堆栈队列