查看 SQLite3 数据库 (XCODE)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4643122/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:38:52  来源:igfitidea点击:

Viewing SQLite3 Database (XCODE)

iphonexcodesqlite

提问by draion

I am creating an iphone app within XCODE the makes use of an SQLite3 database. I am creating the database programmatically if it does not exist. I am not getting any errors when I run the program.

我正在 XCODE 中创建一个使用 SQLite3 数据库的 iphone 应用程序。如果数据库不存在,我正在以编程方式创建数据库。当我运行程序时,我没有收到任何错误。

How can I check the contents of the database to ensure that the data has been inserted correctly into the correct columns? Where does Xcode place the table within my system where I can view it?

如何检查数据库的内容以确保数据已正确插入到正确的列中?Xcode 将表格放置在我系统中的什么位置,以便我可以查看它?

回答by WrightsCS

The SQLite database will be created in your apps Documentsfolder, in the simulator's base directory.

SQLite 数据库将在您的应用程序Documents文件夹中创建,位于模拟器的基本目录中。

Before Xcode 6, you can check in:

在 Xcode 6 之前,您可以签入:

~/Library/Application Support/iPhone Simulator/4.2/Applications/GUID/Documents

There is also a Mac OS X application called SQLiteBrowserthat you can use to browse the database your app created.

还有一个名为SQLiteBrowser的 Mac OS X 应用程序,您可以使用它来浏览您的应用程序创建的数据库。

Update :

更新 :

As of Xcode 6, the new iOS simulator's directory is located here :

从 Xcode 6 开始,新的 iOS 模拟器目录位于:

~/Library/Developer/CoreSimulator

~/Library/Developer/CoreSimulator

Ultimately, you can find your app's database under a location like this (Replace UIDs by yours) : ~/Library/Developer/CoreSimulator/Devices/4D2D127A-7103-41B2-872B-2DB891B978A2/data/Containers/Data/Application/0323215C-2B91-47F7-BE81-EB24B4DA7339/Documents/MyApp.sqlite

最终,您可以在这样的位置下找到您的应用程序数据库(用您的 UID 替换): ~/Library/Developer/CoreSimulator/Devices/4D2D127A-7103-41B2-872B-2DB891B978A2/data/Containers/Data/Application/0323215C-2B91-47F7-BE81-EB24B4DA7339/Documents/MyApp.sqlite

Source: SO: Xcode 6 iPhone Simulator Application Support Location

来源:SO:Xcode 6 iPhone Simulator 应用程序支持位置

回答by Vineesh TP

If you want to view the database that you are created,

如果要查看您创建的数据库,

Open finder press Command+g "~/Library/Application Support/iPhone Simulator" then go.

打开 finder 按 Command+g "~/Library/Application Support/iPhone Simulator" 然后去。

Open 5.0 (as per your version of simulator)-> Application-> select the pgm folder

打开 5.0(根据您的模拟器版本)-> 应用程序-> 选择 pgm 文件夹

-> Documents

-> 文件

enter image description here

在此处输入图片说明

Then you can see the database

然后就可以看到数据库了

enter image description here

在此处输入图片说明

回答by Brabbeldas

The simulator directory has been moved with Xcode 6 to: ~/Library/Developer/CoreSimulator. To find the unique path add the following statement to the AppDelegate.mfile, applicationDocumentsDirectorymethod:

模拟器目录已随 Xcode 6 移至:~/Library/Developer/CoreSimulator. 要查找唯一路径,请将以下语句添加到AppDelegate.m文件applicationDocumentsDirectory方法中:

NSLog(@"%@",[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]);

NSLog(@"%@",[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]);

回答by Omid Ariyan

Xcode 9.1:

Xcode 9.1:

  1. Open Terminal, type:

    cd ~ & find -name "YourModelName.sqlite"

  2. You'll most likely be presented with such a path:

  1. 打开终端,输入:

    cd ~ & find -name "YourModelName.sqlite"

  2. 您很可能会看到这样的路径:

~/Library/Developer/CoreSimulator/Devices/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/data/Containers/Data/Application/YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY/Library/Application Support/

~/Library/Developer/CoreSimulator/Devices/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/data/Containers/Data/Application/YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY/Library/Application Support/

  1. Open Finder, press Shift + Command + G, paste the path and press Go.
  2. Use DB Browser for SQLiteto view the .sqlite file.
  1. 打开 Finder,按 Shift + Command + G,粘贴路径并按 Go。
  2. 使用DB Browser for SQLite查看 .sqlite 文件。

回答by Kendall Helmstetter Gelner

There are a bunch of standalone programs that look at sqllite files. A very popular one for the Mac is called "Base":

有很多独立程序可以查看 sqllite 文件。Mac 上非常流行的一种称为“Base”:

http://itunes.apple.com/us/app/base/id402383384?mt=12

http://itunes.apple.com/us/app/base/id402383384?mt=12