Friday 1 March 2013

Easy access sqlite database of your iPhone app

There several ways to access a specific sqlite database for an iPhone app you are developing. I will show two simple ways to achieve it.
1. Using the Terminal with command line:

  • You need to find where your sqlite database used by your iPhone app first. It is located:
/Users/(Your User Name)/Library/Application Support/iPhone Simulator/(version)/Applications/(App's UUID)/Documents/xxxx.sqlite
  • The sqlite tool is in /usr/bin directory.
  • Here is the example for enter sql commands. (command ".tables" will show all tables in this database)
  •  Issue a simple SQL command(select * from table), and you will get the result. If you want to see the column header, simply enter ".header on" and it will show the header as shown below.




2. Use a browser(Firefox) to access the sqlite:
  • Never thought about that the browser can view your local database, don't you? Here is something even better. It's free!!! Just download and install the Firefox plugin to your Firefox browser. Download the plugin.
  • After install the plugin and restart your browser, open it by clicking on Tools->SQLiteManager in the Firefox's menu. Then you will see the SQLite Manger window pops up. The Firefox menu will change as well. Select Database->Connect Database in the menu as shown below.
 
  • Then find your SQL file in your local directory.
  • Now you can see the whole database easily.

No comments:

Post a Comment