Reputation: 101
I'm trying to sync/upload my core data database/.sqlite file to dropbox. once my user logs in, i have a button to upload the file:
-(IBAction)sync{
NSString *localPath = [[NSBundle mainBundle] pathForResource:@"cache" ofType:@"sqlite"];
NSString *filename = @"cache.db";
NSString *destDir = @"/";
[self.restClient uploadFile:filename toPath:destDir withParentRev:nil fromPath:localPath];
}
But the problem here is: I dont know the name of my .sqlite data base, I've looked under :
~/Library/Application Support/iPhone Simulator/<SDK>/Applications/<UUID>/Documents/bc.db
//I have looked into every file also and i couldnt find a .sqlite
file.
But i cannot find any file called:app name.sqlite
I can only find cache.db
so, im not sure what im supposed to do from here? Can i upload the cache.db file? or is there another file that is app name.sqlite
? Any help is greatly appreciated!
Upvotes: 2
Views: 2664
Reputation: 70976
The SQLite file is wherever you created it. There's no mystery-- you have to tell Core Data where you want the file, and it goes where you say it should go.
If you used one of Apple's project templates you probably have a line in your app delegate class (in the persistentStoreCoordinator
method) that looks like
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"MyApp.sqlite"];
That's where it is, and that's how you should find the file path in your app.
That might be everything. If you're not using binary attributes with "Allows External Storage" checked, it's the entire data store. If you are using those, there's a parallel, hidden directory whose name is undocumented that contains the external binaries.
Copying the data store to Dropbox is not likely to be useful. You cannot sync your data store from one device to another this way-- data corruption is virtually guaranteed.
Upvotes: 4