Open sqlite database file inside iphone simulator?

I find it difficult to understand the problem in my iphone application.

I have a set method in my sqlite database that looks like it is working fine. I do an NSLog when I set the value, and that is correct. This is the line with the value "2010-10-10 12:13:14".

When I use the get method for the same data, it turns out that this value is incorrect. It returns 1.

Is there a way to open the database file that is inside the iPhone simulator so that I can see what actual data is stored in the simulator database?

Is there a way to sniff sqlite calls between my simulator and the actual file? Something like Charles or Capture Service?

Many thanks!

+7
source share
6 answers

You can refer to the following link below, you can definitely look at the database stored in the simulator.

How to view data in sqlite file running in iphone application?

Greetings

+7
source

If you want to view the created database,

Open the crawler → press SHIFT + Command + G → "~ / Library / Application Support / iPhone Simulator", then open.

Open 5.0 (according to your version of the simulator) → Application-> select the pgm folder

-> Documents

enter image description here

Then you can see the database

enter image description here

+22
source

Since iOS 8 put it in another folder:

Library/Developer/CoreSimulator/Devices/(numbers and letters)/data/Containers/Data/Application/(numbers and letters)/Documents/

Check this answer for more info.

+12
source

For simulator 6.1, the location is different.

Start with:

 ~/Library/Application Support/iPhone Simulator/6.1/Applications/ 

Open the folder representing the application on your simulator. The name will look something like this:

 0951F670-1DAC-9A39-450A-B8EEFFC0FFE1 

If you have several folders, you can click on each folder and see the application icon until you find the application you are looking for. In addition, remove all other applications from the simulator, except for those that interest you.

From inside this folder, go here:

 Library/Application Support/<APP_NAME>/<APP_NAME>.sqlite 

The full path should look like this:

 ~/Library/Application Support/iPhone Simulator/6.1/Applications/<APP_ID>/Library/Application Support/<APP_NAME>/<APP_NAME>.sqlite 
+5
source
 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSLog(@"path is %@",documentsDirectory); 

The above code will print the ur database path and copy it. Go to the search device and select "go to folder" from the menu ( Shift + Win + G ) and paste the path here, it will give you the exact path to the kernel data file. Do not open this window.

Next step Go to Mozilla firefox, click on the menu, select Tools → SQLite Manager. He will open a new window. In a new window, click on the open file and drag this path of the coredata file into the current window and click on the open.

Note. Your Mozilla browser must have SQLite Manager installed.

+3
source

Update: I created a tool to automate this

Both for Android and iOS, it is available here.


An old question, but Apple seems to keep changing the logic ...

In macOs Sierra, you can find the database location by issuing the following commands (the simulator should start during the process!)

 ps aux | grep 'CoreSimulator/Devices' 

As a result, the path to the simulator should be indicated, for example:

 /Users/user1/Library/Developer/CoreSimulator/Devices/25C1F5DA-E528-4BC2-B684-A92D382553AC/data/var/run/launchd_bootstrap.plist 

Browse to the simulator folder already found:

 cd /Users/user1/Library/Developer/CoreSimulator/Devices/25C1F5DA-E528-4BC2-B684-A92D382553AC/Data/Application/ 

This folder contains all the simulator applications.

From here, if you know the name of the database, just find it, for example:

 find ./ -type f -name 'my_db.db' 

And viola! You have a database path :)

+2
source

All Articles