Can I back up my app's SQLite database to iCloud? - ios

I'd like to have a 'backup' and 'restore' button in my app that just copies the entire SQLite database as a blob to iCloud. The database will always be small as it contains only hand-entered information.
Is this possible using iCloud or do I need to create an external service to manage this?
(If it matters: my app is created using the NimbleKit framework and jQuery Mobile UI)

answer: it is possible.
iCloud + Storage of media in iPhone Documents folder & Will iCloud sync the files in Document folder of all apps?

Related

Best option For Syncing Documents Directory Between Devices

I want to keep an apps documents directory that contains sqlite using core data files in sync across users' devices. The sqlite files are the only files in the apps documents directory and simply need to be common to all users' devices
I've tried zipping up the sqlite files to send by email, which works with iTunes file sharing but is not suitable for my needs as it can expose the files to other users' devices.
I've tried using app groups to keep the directory common across devices http://blog.sam-oakley.co.uk/post/92323630293/sharing-core-data-between-app-and-extension-in-ios,
and
Accessing Core Data SQL Database in iOS 8 Extension (Sharing Data Between App and Widget Extension) but that simply did not share the directory across devices for me.
I've sent the file to parse, but pulling them down and reconfiguring the data was the problem there.
I've tried using iCloud and even the Apple engineer gave up on that one.
What I'm after is the simplicity of file sharing through iTunes (being able to replace the sqlite files) with a bit more finesse and without the need to plug in the device.
Some considerations
The whole model can be synced in one go
Data does not need constant syncing facilities, a manual sync option would suffice.

Is Core Data sqlite database in the documents directory automatically backed up by iCloud?

I'm working on a project that requires the Core Data database to be backed up somehow so that the data won't be lost if user deletes and re-downloads the app.
In the iOS storage guideline it states:
Only documents and other data that is user-generated, or that cannot otherwise be recreated by your application, should be stored in the /Documents directory and will be automatically backed up by iCloud.
I wonder whether it means that if I put my Core Data sqlite database in the /Documents directory, it will get backed up automatically by iCloud?
If not, is there any simple solution for backing up the Core Data database? I just need the database to be recoverable after app being removed and re-installed. Syncing between devices isn't my aim here.
Yes, putting your database in the Documents directory will do exactly what you want: allow back up to iCloud without syncing to iCloud.
Syncing requires moving to the ubiquity container, but thats not what you want.
More information can be found in the Apple Technical Note which explains how to exclude a file from backup. Of course, for the backup to work, the user has to have set up their device to back up to iCloud.
Edit: Here is another helpful link: Apple's App Backup Best Practices section of the iOS App Programming Guide.

Should I follow iOS Data Storage Guidelines?

My iOS app is intended to be compatible with iOS 5.0 and above, and it has iCloud capabilities turned off in it's target settings, I'm not integrating with iCloud. My app stores an sqlite file and some image files into Documents folder. The sqlite file is not downloadable, but images are.
I've read some posts from people saying that their app's submission was rejected because they don't met the iOS Data Storage Guidelines, but I'm not sure if that is only required if your app has iCloud capabilities enabled, is it? Should I set the NSURLIsExcludedFromBackupKey for my files anyway?
Thanks in advance
EDIT
I've read this here:
It is not possible to exclude data from backups on iOS 5.0. If your app must support iOS 5.0, then you will need to store your app data in Caches to avoid that data being backed up. iOS will delete your files from the Caches directory when necessary, so your app will need to degrade gracefully if it's data files are deleted.
But I need the sqlite file to be in Documents to insert data... how should I handle this?
It has nothing at all to do with whether your app uses iCloud or not. It has to do with the user performing backups to iCloud which is beyond the control of your app.
If all of the data in your app that is stored in the app sandbox is data that is created and stored by the user through the use of the app then Apple will have no problem with the data being backed up.
They have issue with replaceable files being backed up needlessly. If the database file is read-only and could be obtained from a server or the app bundle then don't let it be backed up. But if it starts out mostly empty and then gets data added as the user adds data through the app then it should be backed up. Same for the images.

retain program data in iOS app while updating and sync to iCloud

When a new upgrade is released and installed on iOS, which folders / files are left untouched by the upgrade process? There are several folders; Library, Caches, Preferences, Documents.
Normally Application Support Directory is not created by default. What happen to AS folder during upgrade?
I learn that all data in Documents folder will copy to iTunes or iCloud by default. Is that true?
If I create my own CoreData db to persist, where should I keep?
Your best bet is to read the first half (which pertained to iOS) of this document from Apple:
In my experience, I put Core Data db in Documents folder if the iTunes File Sharing feature was not enabled on your app. Otherwise create a folder in the Library folder called Application Support or anything name, etc. With iTunes File Sharing enabled, user can accidentally delete any files in the Documents folder.
During the upgrade, the contents of Library and Documents folder are retained.

Is iOS 5 iCloud Backup save webkit data for app using the storage of a UIWebView?

I have a phonegap iOS app using the sqlite DB of Webkit (through UIWebView), and I wonder if the sqlite data will be saved with iCloud Backup (iOS5). The sqlite data are stored in Library/WebKit folder. In the apple doc, they say:
The placement of files in your application’s home directory determines what gets backed up and what does not. Anything that would be backed up to a user’s computer is also backed up wirelessly to iCloud. Thus, everything in the Documents directory and most (but not all) of your application’s Library directory.
But it can say exactly which folder in the library directory are not saved. And I don't know how to access iCloud to check if the directory is saved
Library/WebKit is included in the backup. With the exception of Library/Caches, everything in the Library directory is backed up.
The data included in an iCloud backup for your app is identical to that included in an iTunes backup, so you can examine the contents by backing up to iTunes and using a tool like iPhone Backup Extractor to see what's included.

Resources