简体   繁体   English

如何从iPhone应用程序访问Xcode数据库

[英]How to access Xcode database from iPhone app

This is my first iPhone app. 这是我的第一个iPhone应用程序。 I'm using Xcode 7.3. 我正在使用Xcode 7.3。

In the app I used this tutorial to create an sql database using the app (when the user gives permission by pressing a button, it creates the .db file). 在该应用程序中,我使用本教程使用该应用程序创建了一个sql数据库(当用户通过按按钮授予权限时,它将创建.db文件)。

Now I would like to know how I can download the database from the app. 现在,我想知道如何从该应用程序下载数据库。

Here is why: 原因如下:

The app will be downloaded on someone's device (not via the app store). 该应用程序将被下载到某人的设备上(而不是通过应用程序商店)。 It is supposed to collect data from a wearable device and store it in the database. 它应该从可穿戴设备中收集数据并将其存储在数据库中。

However I don't know how to access that data later on when I have the user's phone. 但是,我不知道稍后在拥有用户电话时如何访问该数据。 Apparently the db lives in 显然,分贝住在

/var/mobile/Containers/Data/Application/###/Documents

I read that one method is "jailbreaking." 我读到一种方法是“越狱”。 But I have never done that and this is not my phone I'm dealing with, it's a client's, so I don't feel comfortable hacking it. 但是我从来没有做过,这不是我要处理的手机,而是客户的手机,因此对它进行黑客操作感到不舒服。 Is there another way? 还有另一种方法吗? Possibly through the terminal (this is how I did it with the android app, using adb)? 可能通过终端(这是我使用adb使用android应用程序执行的操作)?

Or is there another way I can go about saving the database so that it is accessible/retrievable? 还是有另一种方法可以保存数据库,以便对其进行访问/检索?

The first answer is correct but incomplete : 第一个答案是正确的,但不完整:

Once you have download the Container, the extension is .xcappdata, so you need to right-click on it and select show the package. 下载容器后,扩展名为.xcappdata,因此您需要右键单击它并选择显示包。

Then browse into /library/Application support/ to find your database in .sqlite 然后浏览到/ library / Application support /在.sqlite中查找数据库

You can try to connect the device to your Mac, then in XCode, go to Window, Devices, select your device and app bundle and click "Download Container...". 您可以尝试将设备连接到Mac,然后在XCode中转到“窗口”,“设备”,选择设备和应用程序捆绑包,然后单击“下载容器...”。 在此处输入图片说明

To see the database, you could use SQLite . 要查看数据库,可以使用SQLite

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM