Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is my sqlite data stored in iOS simulator?

I created an iPad app on xCode(using PhoneGap) with sqlite plugin, stored data, and then when I want to view the data I stored I couldn't find where I saved it. According to my online research, it should be under /Library/Developer/CoreSimulator/Device

However when I navigate to the /CoreSimulator file, I don't see a sub-folder "/Device", just "/Profiles/Runtimes"?

When I reopen the app and wanted to check my stored data I couldn't see them aswell.

like image 488
michelle9090 Avatar asked Aug 31 '16 05:08

michelle9090


People also ask

Where is SQLite database stored iOS?

The database that can be used by apps in iOS (and also used by iOS) is called SQLite, and it's a relational database. It is contained in a C-library that is embedded to the app that is about to use it. Note that it does not consist of a separate service or daemon running on the background and attached to the app.

Where does SQLite store data?

The Android SDK provides dedicated APIs that allow developers to use SQLite databases in their applications. The SQLite files are generally stored on the internal storage under /data/data/<packageName>/databases.

How open SQLite file in iOS?

Xcode 10.1 In the Devices tab, select your application, then click on the Gear icon, then click Download Container... Choose the location you want to save the file, then click on Save. I recommend downloading DB Browser for SQL File, and opening the . sql file with that.

How do I see SQLite database in Xcode?

Xcode 9.1: Open Finder, press Shift + Command + G, paste the path and press Go. Use DB Browser for SQLite to view the . sqlite file.


2 Answers

let dirPaths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)

let docsDir = dirPaths[0]

print(docsDir)

Get the path printed in the debugger, copy it, open finder and press Cmd+Shift+G. A dialog box of Go to folder will open and paste the path and hit enter. You will be navigated to that folder. All the documents created in your project will be present in that folder including the .sqlite file. Don't try to navigate to that folder manually. Chances are you are looking at the wrong folder.

Also don't worry when every time Xcode prints a different path. Its a change brought from Xcode 6 onwards. Don't know why. But your files(those documents) will probably stay updated.

like image 103
Yash Tamakuwala Avatar answered Oct 19 '22 19:10

Yash Tamakuwala


This is My app's folder:

/Users/***/Library/Developer/CoreSimulator/Devices/4420949E-AD14-4A4F-9153-53891734BEB9/data/Containers/Data/Application/0A18183F-2CF6-4D72-938D-DF59CFA48CCF

you can find your app's folder by the following code:

NSString *strPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];

Or just add a plugin: NCSimulatorPlugin

like image 7
shiyj Avatar answered Oct 19 '22 21:10

shiyj