Appcelerator getting a SQLite database to backup and restore with iCloud Backup - ios

My app is live on the app store and users are reporting they cannot see their data after restoring the app to a new or reset iOS device.
The app uses a SQLite database created in the default Library/Private Documents folder by Appcelerator SDK.
I've set the remoteBackup = true flag on the database file, but I'm confused as to whether Apple even backs up from this folder, or whether the database needs to be in the Documents folder to be included in backup?
It should be noted that the database is likely to remain quite small, say 200-300Kb.
Has anyone employed a successful strategy to ensure locally stored SQLite data restores ok?

Related

Sqlite database and app upgrade process doubts

We have stored our app sqlite database in the Library folder. We need that for future app upgrades from app store, the database included in the upgraded app to delete the database from the installed one when users download it from app store. We have checked from different sources, and they say that only the content in Documents folder will not be deleted.
Please can you confirm this point?
Thanks
The Library folder will survive an app upgrade. It's possible that Library/Caches will be deleted but not Library in general.
The simplest solution is to have the new version of your app use a different filename for the database file and have code that looks for and deletes the old database file.

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.

Backup and Restore sqlite db during new version release

I am working on an iPAD application. When a new version is released, I add the version number on the server side db and call it through a webservice and check with the build version of the app. If there is change in the version I am calling a URL to install the new version of the app. What will be the possible solution, not to lose my data from the iPAD app and once the new app is installed I use back the same sqlite db. FYI... I am not using any MDM, and installing the app through an URL. Let me know if I need to explain more in detail.
In the past, app version update usually reset the data to the bundle as packaged in the archive (ipa). The user data in the databases then become lost. (Note: this may have changed in IOS 7 because of the announced incremental update options but I have never been able to check it out).
My way around this is to provide a backup restore facility that creates a Plist in the /Document Folder. this allows the user to extract his data through iTunes File sharing, then restore it back if he or she wishes. If you have a server though, a better way would be to create folders for registered users and program the facility to back / restore from the server. Prompt the user to use the backup prior to any update, and prompt the user to restore data from the server (if available and the database is empty).

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.

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