从电子邮件导入 sqlite 数据库?

发布于 2024-11-02 02:11:20 字数 523 浏览 0 评论 0原文

我已经让我的应用程序调用,从电子邮件导入我的数据所需的功能,但我不确定下一步。该应用程序传递了一个网址,但我不确定如何将该网址下载到我的应用程序文档目录中。我正在尝试下载 a.sqlite 文件。谢谢。

编辑:好的,基本上我无法将我的 data.sqlite 文件从我的电子邮件帐户返回到我的应用程序中。目前,我可以选择使用我的应用程序打开,这样就可以了,我可以看到文件的 URL,但我不确定如何将文件从该 URL 获取到我的应用程序的文档文件夹中,以便我可以用它做一些事情。我一直在尝试使用

NSString *Newpath = [[NSString alloc] initWithFormat:@"%@/new.sqlite",documentPath];
NSData *backup = [NSData dataWithContentsOfURL:url];
[backup writeToFile:Newpath atomically:YES];

where url 是作为运行时传入的 url。希望这能澄清一点。感谢您提供的任何帮助。

I have got my app to call, the required functions to import my data back in from an email, but I am not sure of the next step. The app gets passed a url but i am un sure as to how i actually going to download that URL into my apps document directory. I am trying to download a.sqlite file. Thank you.

EDIT:Ok, basicly i am having trouble getting my data.sqlite file from my email account back into my app. At the moment, i can select open with my app and that works, i can see the URL of the file but i am unsure how i get the file from that URL into the documents folder of my app so i can do something with it. i have been trying to use

NSString *Newpath = [[NSString alloc] initWithFormat:@"%@/new.sqlite",documentPath];
NSData *backup = [NSData dataWithContentsOfURL:url];
[backup writeToFile:Newpath atomically:YES];

where url is the url passed in as run time. Hope that clears thins up a bit. Thanks for any help you can offer.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

反差帅 2024-11-09 02:11:20

好吧,我现在感觉很愚蠢,过去一个小时我一直工作正常,但一直在我的 mac 上查找错误的目录,所以我看不到正在创建的新文件。对于遇到这个问题的其他人,我解决了这个问题,

NSString* documentPath =[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; 

NSString *Newpath = [[NSString alloc] initWithFormat:@"%@/backup.sqlite",documentPath];

NSData *backup = [NSData dataWithContentsOfURL:url]; 
[backup writeToFile:Newpath atomically:YES]; 

很抱歉浪费了大家的时间

Ok, i feal stupid now, i have had this working fine for the last hour but have been looking in the wrong directory on my mac so i couldnt see the new files being created. To anyone else with this issue, i solved it with this

NSString* documentPath =[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; 

NSString *Newpath = [[NSString alloc] initWithFormat:@"%@/backup.sqlite",documentPath];

NSData *backup = [NSData dataWithContentsOfURL:url]; 
[backup writeToFile:Newpath atomically:YES]; 

sorry for wasting everyones time

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文