Problem Description: My DB image MP3 file is copied to the/documents directory when the user launches the app.
In particular, we found this on launch and/or content download, your app stores 2.02 MB. To check how much data your app is storing:
-Install and launch your app
-Go to Settings > ICloud > Storage & Backup > Manage Storage
-If necessary, tap "Show all Apps"
-Check Your app ' s storage
The main English is that, in addition to the user's own creation of files, other files such as the app's own offline files, can not be saved to icloud, which is Apple's storage rules.
Problem solving:
1, it is best not to put the app's own generated files and user files in a file directory, easy to get the path later.
2. How to prevent files from being backed up to icloud and itunes
Starting with iOS 5.1, apps can use the Nsurlisexcludedfrombackupkey or Kcfurlisexcludedfrombackupkey file properties to prevent files from being backed up. These APIs are additional properties that are set directly through the old, deprecated way. All running on iOS5.1 should use these API packages to prevent files from being backed up.
Prevent files from being backed up on iOS5.1
-(BOOL) Addskipbackupattributetoitematurl: (Nsurl *) URL
{
ASSERT ([[Nsfilemanager Defaultmanager] Fileexistsatpath: [URL Path]]);
Nserror *error = nil;
BOOL success = [URL setresourcevalue: [NSNumber Numberwithbool:yes]
Forkey:nsurlisexcludedfrombackupkey Error: &error];
if (!success) {
NSLog (@ "Error excluding%@ from backup%@", [URL lastpathcomponent], error);
}
return success;
}
How does the Addskipbackupattributetoitematurl method work?
Then change this in the app DELEGATE.M:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
documentsDir = [paths objectAtIndex:0];
[self addSkipBackupAttributeToItemAtURL:[NSURL fileURLWithPath:
documentsDir
];
这样就可以保证app的documents文件内容不备份到icloud上,其他文件目录同理。
App shelves, icloud stores too much content.