将我的应用程序的数据库文件从我的开发iPhone导出到我的计算机

时间:2022-11-11 22:49:03

I've got an iPhone app under development that I plan on using for research purposes. As testers use the app on my development phone, it stores analytics data in a local database (right now SQLite, but I'm not opposed to migrating to CoreData).

我有一个正在开发的iPhone应用,我计划用于研究目的。当测试人员在我的开发手机上使用这个应用程序时,它会在本地数据库中存储分析数据(现在是SQLite,但我并不反对迁移到CoreData)。

After testing is done, I need to be able to copy this analytics database off of the phone onto my computer so I can run queries on the data. What is the easiest way to accomplish this? If necessary I'll iterate through the data, print it to the device log, and then import it back into a database on the desktop, but I'd like to find a way to just grab the .sqlite file without running it through an intermediary format.

测试完成后,我需要能够将这个分析数据库从手机上拷贝到我的计算机上,这样我就可以对数据进行查询。最简单的方法是什么?如果需要,我将遍历数据,将其打印到设备日志中,然后将其导入到桌面的数据库中,但是我希望找到一种方法,在不通过中介格式运行.sqlite文件的情况下获取它。

4 个解决方案

#1


1  

You can use the Xcode Organizer to download a zipped snapshot of your app's Documents and Library directories from your device.

您可以使用Xcode管理器从您的设备下载应用程序文档和库目录的压缩快照。

#2


1  

You can always try to print it to a PDF, using the UIKit is a simple way to export information and formating in a easy way, unless you think this method can't apply to your database ;)

你可以试着把它打印成PDF格式,使用UIKit是一种简单的方式来导出信息和格式化,除非你认为这个方法不能应用到你的数据库中;)

Do you know if we can email the SQLite database directly from the iOS device?

你知道我们是否可以直接从iOS设备上发送SQLite数据库吗?

#3


0  

Easiest way would be to add the UIFileSharingEnabled key (as a boolean, set to YES) to your Info.plist, then use something like this:

最简单的方法是将UIFileSharingEnabled键(作为布尔值,设置为YES)添加到您的信息中。plist,然后使用如下内容:

NSString *docsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
[[NSFileManager defaultManager] copyItemAtPath:whereverTheDatabaseIs toPath:[docsPath stringByAppendingPathComponent:@"exported.sqlite"] error:NULL];

Then, you or your users will be able to grab the database off the device using iTunes's file-handling malarkey.

然后,你或你的用户就可以使用iTunes的文件处理程序malarkey从设备上抓取数据库。

edited - actually, see Ole's answer: I didn't know about that trick, and it'll probably be much faster.

编辑——实际上,看看Ole的回答:我不知道这个技巧,它可能会快得多。

#4


0  

Thanx ole begemann.

谢谢奥立begemann却。

In organizer open your app and then Download that particular send Box. So It will create a .xcappdata extension file.
You can rename the extension to .zip then you will find the same folder as in InApp directory folder in your finder. and you can work with your data.

在组织者打开你的应用,然后下载那个特定的发送框。它将创建一个.xcappdata扩展文件。您可以将扩展名重命名为.zip,然后您将在查找程序的InApp目录文件夹中找到相同的文件夹。你可以使用你的数据。

#1


1  

You can use the Xcode Organizer to download a zipped snapshot of your app's Documents and Library directories from your device.

您可以使用Xcode管理器从您的设备下载应用程序文档和库目录的压缩快照。

#2


1  

You can always try to print it to a PDF, using the UIKit is a simple way to export information and formating in a easy way, unless you think this method can't apply to your database ;)

你可以试着把它打印成PDF格式,使用UIKit是一种简单的方式来导出信息和格式化,除非你认为这个方法不能应用到你的数据库中;)

Do you know if we can email the SQLite database directly from the iOS device?

你知道我们是否可以直接从iOS设备上发送SQLite数据库吗?

#3


0  

Easiest way would be to add the UIFileSharingEnabled key (as a boolean, set to YES) to your Info.plist, then use something like this:

最简单的方法是将UIFileSharingEnabled键(作为布尔值,设置为YES)添加到您的信息中。plist,然后使用如下内容:

NSString *docsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
[[NSFileManager defaultManager] copyItemAtPath:whereverTheDatabaseIs toPath:[docsPath stringByAppendingPathComponent:@"exported.sqlite"] error:NULL];

Then, you or your users will be able to grab the database off the device using iTunes's file-handling malarkey.

然后,你或你的用户就可以使用iTunes的文件处理程序malarkey从设备上抓取数据库。

edited - actually, see Ole's answer: I didn't know about that trick, and it'll probably be much faster.

编辑——实际上,看看Ole的回答:我不知道这个技巧,它可能会快得多。

#4


0  

Thanx ole begemann.

谢谢奥立begemann却。

In organizer open your app and then Download that particular send Box. So It will create a .xcappdata extension file.
You can rename the extension to .zip then you will find the same folder as in InApp directory folder in your finder. and you can work with your data.

在组织者打开你的应用,然后下载那个特定的发送框。它将创建一个.xcappdata扩展文件。您可以将扩展名重命名为.zip,然后您将在查找程序的InApp目录文件夹中找到相同的文件夹。你可以使用你的数据。