Now that I have a read-only application working, I am working on the insert statement. The insert returned OK in my code, but the read-back (in the code) came up empty, so I want to use the command line or browser to read. Can I copy the DB off the emulator and into my laptop for access with other utilities?
You can access the documents directory of your app at ~/Library/Application Support/iPhone Simulator/<SDK VERSION>/Applications/<SOME RANDOM HASH>/Documents
Note that the SDK version will be different depending on what you are building under, and the hash is tough to figure out which one is yours. Just inspect the folders and look for a YOURAPP.app binary to figure it out.
What database?
Assuming you have created it in your app's documents folder, app sandboxes for the simulator are in ~/Library/Application Support/iPhone Simulator/<version>/<uuid>, and contain the application and it's Documents, Library and tmp directories.
Related
Here's the scenario: I have created a db3 file, attached it to to the solution, changed it to content (tried resource as well), and copying all the time. When I launch the app, I copy this to the document folder of the app. Now, it works flawlessly in the simulator, i.e. I can both read and write. But on the device, it's only in Read-Only mode. How do I make it writable on the device? I am using the latest ios 5 and latest monotouch.
Thanks in advance for any help.
And Merry Christmas everyone :)
Files stored in the .app directory are read-only on device.
If you need to have a read-write version of any of your data files, you need to copy this to your Documents storage area.
I've created an app that uses core data. Is there a way to view the sqlite db on the simulator? A tool perhaps that allows to query the sqlite db on the simulator? Like a data browser?
Is there a way to browse the iphone simulator to the sqlite db location?
With Xcode 6, the simulator base directory can be found here:
~/Library/Developer/CoreSimulator/Devices/<device-id>/data/Containers/Data/Application
Then, the database itself can be found in the documents directory:
<app-id>/Documents/<name>.sqlite
The database can be accessed using sqlite3 on the command line.
Xcode 5
I just downloaded a trial of Base and was able to point it at the .sql database from the simulator via:
/Macintosh HD/Users/"username"/Library/Application Support/iPhone Simulator/"current iOS development version"/Applications/
The folder names for the applications are unreadable, but if you click on the folder you should be able to see the contents with familiar names.
Xcode 6+
This was changed in Xcode 6, and now is located at ~/Library/Developer/CoreSimulator/Devices/<device-id>/data/Containers/Data/Applaction where the database itself can be found within the documents directory <app-id>/Documents/<name>.sqlite
Try Lita, free and quite good.
If you have the free sqlite3 installed, you can do so at the command line by doing:
/Users/<user>/Library/Application\ Support/iPhone\ Simulator/<sim_version>/Applications/<apphash>/Documents/<yourfile>
Easiest way to see which hash you should peek in:
ls -lt /Users/<user>/Library/Application\ Support/iPhone\ Simulator/<sim_version>/Applications/
You can run .tables at the prompt to see what tables are there, and .schema <tablename> to check out its columns.
i´m quite happy with SQLite Manger for Firefox. Free AddOn.
This is a quite an old post, however I was looking for something else and I landed here, my 2 cents:
In reply to WINSergey:
(1) The easiest way to recover your device ID and the entire path is to print:
NSLog(#"app dir: %#",[[[NSFileManager defaultManager]
URLsForDirectory:NSDocumentDirectory
inDomains:NSUserDomainMask] lastObject]);
Then you'll see the output on the Debugging area or opening the System Log from the simulator.
(2) Also, to know the Device ID from the simulator: XCode > WIndow > Devices > > it shows the Identifier on the right hand side.
I'm also using SQLiteStudio, it is Open Source and works well.
I have a lot of data stored in my app on my provisioned device, and I want to do additional testing on my computer which is much faster than using the device. What is the best way to transfer the data store into the iPhone simulator so I can access it on the computer?
I think that you can download the data from your device in the Organizer in Xcode.
Once you unzip that folder you should be able to find your sqlite database file.
Now look for the folder on your hard drive where the simulator keeps its files. I think it's somewhere in ~/Library/Application Support/iPhone Simulator or something like that. There should be a folder for each app somewhere in there (the folder name will be some random ID), and you should be able to find an sqlite database with the same name. Replace that database with the one you downloaded from the device.
Sorry I can't give more detailed instructions. I'm at work currently and don't have access to my Macbook to get the exact folder names and such.
Hi I am new in iphone app, i am just trying out some apps.
I am trying to add more data in my database, i just want to see where it is stored and my database updated or not.
The default for the template projects is that it will save a file named "NameOfProject.sqlite" into the apps document folder.
On the simulator, the app's directories will be in:
(user's home directory)/Library/Application Support/iPhone Simulator/(build iOS version number)/(UUID string)/
The text in the "()" varies.
For example, one of my projects has a path:
(my home directory)/Library/Application Support/iPhone Simulator/3.2/Applications/2E211069-AEF3-4F1F-9CA2-A18EF310F798
The name of the app's directory is a UUID and often changes so you have to constantly check.
I have opened a database using sqlite3 in my application. When i run the application in the simulator, this database might be created and i'm playing with it. But now i need to know the location (to be accessed from ma mac) where this database is created. Surely it is not in the application folder as i'm not seeing it. I doubt it to be somewhere in the location where the simulator is installed. Anyone knowing the location. pls help me finding it.
If you're looking for the actual file on your Mac, try looking in this folder:
/Users/YOURUSERNAME/Library/Application Support/iPhone Simulator/User/Applications/
There should be a bunch of folders with long names. If you've recently built your app for the Simulator, order the folder by Date and the newest will be at the top. The folder contains a Documents folder, but you can also right-click on the app to "Show Package Contents", which might contain your database.sqlite file.