简体   繁体   English

如何在Macbook的iPhone 6s Simulator上找到SQLite数据库?

[英]How to find SQLite db on iPhone 6s Simulator in Macbook?

I am searching for my SQLLite DB in my Simulator. 我正在模拟器中搜索我的SQLLite数据库。

Based on ActivityMonitor, I am able to get the folder path of my Application. 基于ActivityMonitor,我可以获取我的应用程序的文件夹路径。

/Users/MyMacBook/Library/Developer/CoreSimulator/Devices/A4170C16-A10B-4B48-9C7B-2A310F68B35F/data/Containers/Bundle/Application/F6C6772C-021A-4B27-874D-071B402DDBCC/ /用户/ MyMacBook / Library / Developer / CoreSimulator / Devices / A4170C16-A10B-4B48-9C7B-2A310F68B35F / data / Containers / Bundle / Application / F6C6772C-021A-4B27-874D-071B402DDBCC /

Though i couldn't find the SQLite database. 虽然我找不到SQLite数据库。 I work on VS 2015 Xamarin Project. 我从事VS 2015 Xamarin项目。

How should i find SQLite db on my Simulator ? 我应该如何在模拟器上找到SQLite数据库?

Find the location of sqlite file by using the code in your appDelegate in the `didFinishLaunchingWithOptions' 通过使用您的appDelegate中的代码在`didFinishLaunchingWithOptions'中找到sqlite文件的位置

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    print(FileManager.default.urls(for: .documentDirectory, in: .userDomainMask))
}

Every time when running the app, your can find the location printed in the Xcode console. 每次运行该应用程序时,您都可以在Xcode控制台中找到打印的位置。

I'm using application simMagnifier to view the SQLite file 我正在使用应用程序simMagnifier查看SQLite文件

By default , most SQLite libraries/frameworks will place the Sqlite file in the root of your .app . 默认情况下 ,大多数SQLite库/框架会将Sqlite文件放在.app的根目录中。

When you establish your SQLite connection if you are supplying a path and a filename to your SQLite file, then follow that path. 如果要为SQLite文件提供路径和文件名,则在建立SQLite连接时,请遵循该路径。

Example using sqlite-net : 使用sqlite-net示例:

var db = new SQLiteConnection("StackOverflow.sqlite");

Location: 位置:

cd Library/Developer/CoreSimulator/Devices
find $PWD -name "StackOverflow.sqlite" -print

/Users/sushi/Library/Developer/CoreSimulator/Devices/1EB2B821-E86B-4E9A-9814-1BBEF8FF1AA1/data/Containers/Bundle/Application/11BE399A-F802-4410-8163-32F5A90EB2FF/SQLiteLocation.app/StackOverflow.sqlite

Example using Path.GetTempPath : 使用Path.GetTempPath示例:

var db = new SQLiteConnection(Path.Combine(Path.GetTempPath(), "StackOverflow.sqlite"));

Location: 位置:

cd Library/Developer/CoreSimulator/Devices
find $PWD -name "StackOverflow.sqlite" -print

/Users/sushi/Library/Developer/CoreSimulator/Devices/1EB2B821-E86B-4E9A-9814-1BBEF8FF1AA1/data/Containers/Data/Application/EED6E9CE-7437-48DD-904D-5F9D5E8AC78F/tmp/StackOverflow.sqlite

I use to use SimPholders (but it's paid). 我过去常常使用SimPholders(但已付费)。 I found this free open-source alternative called Open Sim . 我找到了这个名为Open Sim的免费开源替代方案。 It lets you browse the directories of the apps on your simulator. 它可以让您浏览模拟器上应用程序的目录。 It makes it super easy to locate the sqlite db in your Xamarin App and then you just need a sqlite viewer to open the actual database. 这使得在Xamarin应用程序中查找sql​​ite db非常容易,然后您只需要一个sqlite查看器即可打开实际数据库。

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

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