-2

I am developing an app on xCode 5, iOS 7. I have some data stored in CoreData. My requirement is to upload that data to RackSpace. Whats the best way to do this? Where can I find .sqlite file associated with CoreData?

user1554693
  • 125
  • 1
  • 12
  • What's best depends on what you hope to be able to do with the data once it has been uploaded. In what way(s) will the data be used after it has been uploaded? – Tom Harrington Dec 14 '14 at 00:30
  • Its a user data, The requirement is to save data on the cloud so that the user can access it on different devices. So the user is able to save the data on the cloud and also download (restore) it whenever required. – user1554693 Dec 14 '14 at 00:41
  • Yes but what will happen with the data after it is uploaded? Is this for backup purposes, or for syncing, or what? – Tom Harrington Dec 14 '14 at 00:42
  • yes, for backup and also syncing. – user1554693 Dec 14 '14 at 00:44
  • Its a user data, The requirement is to save data on the cloud so that the user can access it on different devices. So the user is able to save the data on the cloud and also download (restore) it whenever required. – user1554693 Dec 14 '14 at 01:15

1 Answers1

1

The SQLite file is wherever you put it. There's no magic to it, you have to tell Core Data exactly where you want the file. You do this when you call addPersistentStoreWithType:configuration:URL:options:error:. The URL argument is the location of the SQLite file.

If you try and use the file directly, make sure that:

  1. You shut down your Core Data stack completely before doing so, to make sure that all unsaved data has been flushed to disk. That means no managed objects, managed object contexts, or persistent store coordinators in memory anywhere.
  2. Make sure to get the SQLite journal files. If your store file were named Foo.sqlite, they will be named Foo.sqlite-wal and Foo.sqlite-shm and will be located in the same directory. If you don't get these files, most or all of your data will be missing.

However simply uploading the file is not a good solution for syncing data. To sync data, you'd have to download a copy of the data, load that, and compare every object in the file with every object that's already on the phone. It's not impossible but it's definitely making things much more difficult than necessary. There are many options that can simplify the process, including full service providers like Parse, SDKs that let you use one of a variety of back ends like Ensembles.io, and others.

Tom Harrington
  • 69,312
  • 10
  • 146
  • 170