You do not have to prepare your app in any way for backup and restore
operations. Devices with an active iCloud account have their app data
backed up to iCloud at appropriate times. And for devices that are
plugged into a computer, iTunes performs an incremental backup of the
app’s data files. However, iCloud and iTunes do not back up the contents
of the following directories:
Application_Home/AppName.appApplication_Home/Library/CachesApplication_Home/tmp
- Critical data should be stored in the
/Documentsdirectory. Critical data is any data that cannot be recreated by your app, such as user documents and other user-generated content. - Support
files include files your application downloads or generates and that
your application can recreate as needed. The location for storing your
application’s support files depends on the current iOS version.
- In iOS 5.1 and later, store support files in the
/Library/Application Supportdirectory and add theNSURLIsExcludedFromBackupKeyattribute to the correspondingNSURLobject using thesetResourceValue:forKey:error:method. (If you are using Core Foundation, add thekCFURLIsExcludedFromBackupKeykey to yourCFURLRefobject using theCFURLSetResourcePropertyForKeyfunction.) Applying 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. - In iOS 5.0 and earlier, store support files in the
/Library/Cachesdirectory to prevent them from being backed up. If you are targeting iOS 5.0.1, see How do I prevent files from being backed up to iCloud and iTunes? for information about how to exclude files from backups.
- In iOS 5.1 and later, store support files in the
- Cached data should be stored in the
/Library/Cachesdirectory. Examples of files you should put in theCachesdirectory 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. - Temporary data should be stored in the
/tmpdirectory. 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.
No comments:
Post a Comment