I found out that if I delete an App from the device, all local documents are deleted of course, but if the App has files stored in the iCloud-enabled folder ([[[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil]) - These files are not deleted.
This causes two problems:
The storage taken by these files is not freed.
If the user re-installs the App, there are already files in the folder, which disrupts normal initialization.
I can take care of the second issue by going through the directory on first launch and deleting everything in there, but it seems a bit awkward.
I can't think of a way to take care of the first issue.
Any ideas?
iOS automatically purges files in the iCloud directory to free up space. You may also specifically "evict" files from your app, but since you are addressing the scenario in which the app is deleted, that probably won't be much help.
See the videos at developer.apple.com/icloud for more info.
Related
I am not able the test my case, because I simply don't know when the synchronisation process of syncing files is triggered. Thats why I am asking this here.
I have a lot of files and subfolders in my apps document folder and want to prevent from backup up these files in ICloud (which seems to be stupidly the default).
Is it necessary to mark all these files with
MyFile.setResourceValue(NSNumber.numberWithBool(true), forKey: NSURLIsExcludedFromBackupKey, error: &err)
or is it good enough to only mark the root document folder once and all childs will also be marked with ExcludedFromBackup implicitely ?
u can use it for root directory only
Starting in iOS 5.1, apps can use either
NSURLIsExcludedFromBackupKey or kCFURLIsExcludedFromBackupKey file
system properties to exclude files and directories from backups.
In details look Technical Q&A QA1719
The MyProjectName.app should be in the iPhone App structure directory as read-only, but in the project I have to join Test.sqlite and compile it, then I see the Test.sqlite in the MyProjectName.app.
I posted the project to the physical machine and inserted some data without issues. Is this the right way?
When I add the Test.sqlite and data on the iphone simulator, the Test.sqlite didn't appear to have any data. I have tried to copy the Test.sqlite to Documents. And then when I did it again, the data was displayed in the Documents's Test.sqlite. Do I need Test.sqlite to be copied to the Documents? thank you
The resources which are modified at runtime should be part of Documents directory. iPhone application creates a sandbox environment which is signed. If you try to modify any of the bundle resource, it will not allow. It works fine with simulator but not with device.
So, whatever resources are modified should be copied from bundle to documents directory.
Also, when upgrade is available, bundle is replaced with new version. However documents directory does not change. It remains same. If you want to carry any change with upgrade, you can modify data accordingly.
Hope it helps.
Check the Test.sqlite file is it read only or read/write.Change it into read/write.And if there is any lock for the project just uncheck it.
I know normally I have two choices of places: Temporary folder or Cache folder.
But can anyone tell me the exact differences?
My app will download quite many images upon users' requests. Of course, no one need them on the disk of iphone permanently. But I still need to cache them in the case users will go back to see them in relatively short time period.
Temporary folder can be one place to go, as I understand it will be cleared by the system. But when will it be cleared?
For cache folder, will cache folder be cleared regularly as well? If the cache folder will not be cleared, and I write the images to Cache folder, that will occupy too much spaces in a longer term, and it is not good for the users of course.
So, can someone give me some hints and tell me the exact diff between these two folders?
Thanks
I would go with the Caches folder— look in NSPathUtilities.h for the relevant methods to get at that one. The Caches folder won't be backed up, but it won't necessarily be emptied either, and neither will the temp folder. /tmp would normally be cleared upon reboot (well, potentially), but on the iPhone that's not something that will happen commonly.
The best approach would be to put data into the Caches folder using some date-based scheme, so that you can clear its contents yourself when you deem it useful to do so. You could use the file's creation or modification date to inform this decision, and simply scan at each launch (or each enter-foreground event) to determine which items are old enough that they should be removed.
I want the user to be able to access the files in the documents directory but am using core data and dont want the user to be able to access the store (the sqllite db), can i hide it from the user while still allowing file sharing, or can i put it in another directory where it will still get backed up?
The answer given by FrenchKiss Dev is not correct. The user will still be able to see the ".data" directory in iTunes and save that locally with all the files inside it.
Instead, store private documents in Library/Preferences
According to Apple:
In addition to the directories documented previously, the entire
/Library directory has always been preserved during
updates and backups, except for /Library/Caches.
Because of this, applications can create their own directories in
/Library/ and those directories will be preserved in
backups and across updates. To minimize the risk of name collisions,
we recommend that you name this directory carefully. For example, a
directory named Private Documents would be a good choice. You should
store any files you don't want to share to Library/Preferences.
In the documents directory, create a subdirectory which name starts with a dot. For example:
.data
EDIT: Please stop downgrading this answer !
This answer was correct at the time (remember that it was before the iPad was actually available! And there was a lot of confusion on the matter, we were still hoping for the iPad to appear in the shared devices in the Finder...).
Today (April 2012) it is still working on the Mac but not on Windows (starting a directory name with a dot means nothing in Windows).
Anyway, this Shared Document feature is a mess. Later they fixed it by saying that "Private Documents" should be stored in the Library Folder not in the Documents folder. But remember that developers were already using the Document folder before the iPad came.
Don't blame me for Apple mistakes.
Stack Overflow should have a way to mark an answer as obsolete.
API changes, get fixed, and it renders answers obsolete.
I've written an app that uses some of the user's camera roll images, and while it does so it stores them in the application root directory. The problem I have is that whenever I re-compile my application it changes the folder to which the application is installed.
Is there any way I can specify which folder it should build to, so that any path information stored during it's last run will still be valid?
I don't think that this is something you can stop Xcode from doing unfortunately. It should be copying the data from the old location to the new one but sometimes that just doesn't happen.
The answer suggested in this question looks like the solution you are after.