IOS Data Storage guidelines and "do not back to up" file properties

Source: Internet
Author: User
Tags file url home screen

With icloud in OS 5, Apple has updated its data storage guidelines to accommodate icloud storage while adding "do not back up" file attributes to specify that files are not backed up and uploaded to icloud


Excerpts are as follows, for your reference:


IOS Data Storage Guidelines

icloud includes a backup that automatically backs up users ' iOS devices every day via Wi-Fi. Everything in the app's home directory will be backed up, in addition to the app bundle itself, the cache directory, and the temp directory. Purchased music, apps, books, Camera roll, device settings, home screen, app organization, messages, ringtones will also be backed up. Because backups are done wirelessly and stored in icloud for each user, the app needs to minimize the amount of data it stores. Large files can prolong backup times and consume the user's available icloud space.

to ensure that backups are as fast and efficient as possible, applying stored data requires the following guidelines:

1. Only those user-generated documents or other data, or data that the app cannot recreate, should be stored in the <application_home>/documents directory and automatically backed up to icloud.

2. Data that can be re-downloaded or generated should be stored in the <application_home>/library/caches directory. For example, database cache files, downloadable files (magazines, newspapers, data used by map applications), etc. are in this category.

3. Temporary use of data should be stored in the <application_home>/tmp directory. Although these files will not be backed up by icloud, the app will need to remember to delete the files after use so that it does not continue to occupy the user's device space.

4. Use the Do not backup property to specify files that need to remain on the device, even if there is low storage space. This property is required for those files that can be regenerated, but remain in low storage space, have an impact on the app's uptime, or if the user wants files to be available offline. This property can be used regardless of the file (including the documents directory) in the directory. These files are not deleted and are not included in the user's icloud or itunes backup. Since these files always occupy the storage space of the user's device, it is the responsibility of the application to periodically monitor and delete these files.





IOS 5.0.1 begins to support the "do not back up" file properties, allowing developers to explicitly specify which files should be backed up, which local caches can be automatically deleted, and which files need not be backed up but not deleted. In addition, setting this property on the directory prevents all content in the directory and directory from being backed up.

Note the "Do not back to" property can only be used for iOS 5.0.1 later versions. Previous versions of the app need to store data to the <application_home>/library/caches directory to avoid being backed up. Since the old system ignores this attribute, you need to make sure that the app is in all iOS versions and follows the iOS Data Storage guidelines above.

Data Processing Classification
The com.apple.MobileBackup file property is an iOS 5.0.1 introduction to the "Do No Back Up" feature that specifies that a file or directory does not need to be backed up (regardless of where the file system is located). By using this new file attribute and storing the file in the specified directory, the file can be divided into the following four types of data: S.

Key Data
These are user-created data, or other data that cannot be regenerated. Should be stored in the <application_home>/documents directory and should not be marked as a "do not backup" property. Critical data is retained in low storage space and is backed up by icloud or itunes.

Cache Data
data that can be re-downloaded or generated without this data will not prevent users from using the app's functionality offline. The cached data should be stored in the <application_home>/library/caches directory. Cached data may be deleted when the device is low on storage, and itunes or icloud will not back it up.

Temporary Data
applications need to write to local storage, using temporary data internally, but do not need to be retained for long-term use. Temporary data should be saved in the <application_home>/tmp directory. The system may empty the data in that directory, nor will itunes or icloud back it up. Applications that do not need to use this data should delete temporary data as soon as possible to avoid wasting the user's storage space.

Offline Data
can be downloaded or recreated, but users want to be able to access the data when they are offline. Offline data should be stored in the <application_home>/documents directory or the <application_home>/library/private documents directory and marked as "Do not Backup property. The data in both locations is preserved when the storage space is low, and the Do not backup property blocks itunes or icloud backups. When an app no longer needs an offline data file, it should be deleted as soon as possible to avoid wasting the user's storage space. CE.


Setting the Do not backup extended property
Note: The "Do not backup" extended property can be added to any file or directory and can be set on older versions of the system. However, the old system will still back up these files, and once the device is updated to iOS 5.0.1, the files will be properly configured again.

use the following method to set the do not back to extended property. When you create a file or directory that does not need to be backed up, write data to the file, and then call the following method and pass a file URL.

Set Extended Properties
#include <sys/xattr.h>
-(BOOL) Addskipbackupattributetoitematurl: (Nsurl *) URL
{
const char* FilePath = [[URL path] filesystemrepresentation];

const char* attrname = "Com.apple.MobileBackup";
u_int8_t attrValue = 1;

int result = Setxattr (FilePath, Attrname, &attrvalue, sizeof (AttrValue), 0, 0);
return result = = 0;
}

1 //Set Extended Properties2#include <sys/xattr.h>3-(BOOL) Addskipbackupattributetoitematurl: (Nsurl *) URL4 {5 Const Char* FilePath =[[URL Path] filesystemrepresentation];6  7 Const Char* Attrname ="Com.apple.MobileBackup";8u_int8_t AttrValue =1;9  Ten intresult = Setxattr (FilePath, Attrname, &attrvalue,sizeof(AttrValue),0,0); One returnresult = =0; A}

Original link: http://www.cocoachina.com/bbs/read.php?tid=86244

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.