将核心数据库/ .sqlite文件同步到Dropbox [英] Sync core data database/ .sqlite file to Dropbox

查看:205
本文介绍了将核心数据库/ .sqlite文件同步到Dropbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将核心数据库/ .sqlite文件同步/上传到Dropbox。
一旦我的用户登录,我有一个按钮上传文件:

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];
}

但是这里的问题是:我不知道我的.sqlite数据的名字基础,我看下:

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

//我已经查看每个文件,我找不到 .sqlite 文件。

//I have looked into every file also and i couldnt find a .sqlite file.

但我找不到任何文件: app name.sqlite 我只能找到 cache.db 所以,我不知道应该从这里做什么?我可以上传cache.db文件吗?或者是否有另一个文件 app name.sqlite ?非常感谢任何帮助。

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!

推荐答案

SQLite文件是您创建它的地方。没有什么神秘的 - 你必须告诉Core Data你想要的文件,它就在你说它应该去的地方。

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.

如果你使用苹果的项目模板您可能在您的应用程序委托类(在 persistentStoreCoordinator 方法中)有一行如下

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.

这篇关于将核心数据库/ .sqlite文件同步到Dropbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆