On my work, technology and related stuff....

Archive for September 2011 | Monthly archive page


Earlier this week, I jailbroke my iPhone4 iOS4.3.5 device. The jailbreak solution that is currently available for iOS4.3.5 is tethered jailbreak. If you are not familiar with “Tethered Jailbreak”, it essentially means that rebooting the jailbroken device would require it to be connected /tethered to the PC/MAC. This is of course not ideal but under the circumstances, this was my only option (And no-I couldn’t downgrade to iOS 4.3.3 for various reasons which are not directly relevant to this post).

Installing the jailbreak Software

I used Redsn0w V0.9.8b3 jailbreak tool. Follow the instructions provided here. The process is very straightforward.

Cydia Crashing Issue

Although the jailbreak completed successfully, the Cydia icon was white and it crashed as soon as I clicked on it. To get around it, I rebooted the device by running Redsn0w in tethered mode. Be sure to check the “Just boot tethered right now” option on Redsn0w . Once the device rebooted, the Cydia app started working. No more crashes. I was able to download and install apps.  Unfortunately, some of them required a reboot and I had to go through the tethered reboot process again
The  MobileTerminal, OpenSSH and Aptupdate for SBSettings were among the packages that I installed. These packages will come in handy as you will see below.

Installing third party apps directly

Next, I wanted to install a third party app directly to the phone. The third party app was not available through Cydia sources or the AppStore.
For this, I copied the .app file corresponding to my app into the /Applications folder on the iPhone , created the /var/mobile/Documents folder and updated the file permissions by running the commands listed below from a terminal window on my MAC. Ofcourse,  I substituted "IPhoneIPAddress" with the IPAddress of my jailbroken phone while executing the commands

Note: Creation of the Documents folder is required only the first time (unless you delete it between installations)
I rebooted the device in tethered mode. When the device rebooted, the app was ready. I could launch it and run it.
So far, so good until..

I tried to launch Cydia app, it crashed. All the other apps on the phone worked as normal.

Cydia Crashing Issue..Again.

So I rebooted the phone again in tethered mode.  This time the reboot had no effect. The other option was to re-jailbreak but I did not want to do that just yet.
Instead, I uninstalled and re-install the Cydia app by running the following commands from the terminal window of my MAC.  I substituted "IPhoneIPAddress" with the IPAddress of my jailbroken phone while executing the commands

Note: The AptUpdate for SBSettings that I installed earlier automatically installed the apt tools .
Once I did that, cydia was back up and running again. I currently have version 1.1.1 of Cydia on the phone. Everything else continues to work as expected.
Now, its appears that installing the third party app caused Cydia to crash but it is unclear to me why that was the case because Cydia started working again after re-installation and the third party app continues to work as well. In any case, now I know what I should do to resolve the problem should it resurface but its less than ideal.

In Conclusion..

With the number of reboots that I had to do, the tethering is especially tedious. If you are considering jailbreaking your iOS device, I would recommend that you refrain from updating it to 3.4.5. for now and wait for an untethered release of jailbreaking software if possible.

No comments

The SQLite engine is a lightweight library optimized for managing relational databases in embedded environments. It is supported on the iOS platform. Described below is a set of basic SQLite queries that will come in handy if you need /choose to use the C-style SQLite APIs to directly manipulate your database tables. It is intended for folks who are noobs to the database world. Direct manipulation using SQLite APIs is an alternative to using the high-level Object Oriented Core Data wrapper framework.

Note: The sample code snippets are intended for reference purposes. You should include appropriate error handling and any relevant synchronization support depending on the needs of your application. If you are interested in the details of the routines, please refer to the sqlite3.h header file.

Adding SQLite Support

SQLite libraries is available as part of the iOS SDK.  Include the libsqlite3.0.dylib to your project using the usual procedure, and add
#import <sqlite3.h>  to the relevant header files.
Note: The following code snippets assume an ivar named “dbHandle” corresponding to the database Handle defined in your header file as follows-
sqlite3* dbHandle;

Opening the connection to the database

The following code snippet creates a database file named “AddressBook.sqlite” within the Documents folder of the application. If the database exists, it opens a connection to the database.

Creating a table

The following code snippet creates a table named “Contacts” in the “AddressBook.sqlite” database. Every row in the table corresponds to a “Contact” and has the following columns-


VARCHAR (non-null)


VARCHAR (null)


VARCHAR (null)


VARCHAR (null)


Common queries on a table

Query execution follows the following basic sequence –

  • Prepare” the SQL query for executing using the sqlite3_prepare_v2() call. A SQL query can be comprised of multiple SQL statements, That said, the “preparation” routines only compile the first SQL statement in the query so I typically specify only one statement within a query.
  • Optionally,“Bind” SQL query arguments with values using the sqlite3_bind_*() commands. Binding would be required only if there are arguments specified in the SQL query statement.
  • Evaluate” the compiled SQL query (that was output from the sqlite3_prepare_v2() command ) using the sqlite3_step() command.
  • Optionally, “Retrieve” the results of the SQL query evaluation using the sqlite3_column_*() commands.You can access the value of every column of the resulting row using these routines. The leftmost column begins at index 0.
  • Reset” the compiled SQL query so it can be evaluated again. You can execute the query again using the sqlite3_bind() and sqlite3_step() commands
  • Destroy” the query object once you are done with the query using the sqlite3_finalize() command

Fetch total number of entries in the table

The code snippet returns the number of rows in the Contacts table

Add a row entry to the table

The code snippet adds a new Contact entry to the Contacts table

Select a row entry from the table

The code snippet selects an entry in the Contacts table with FirstName = “Foo” . It also retrieves the rowId corresponding to the entry.


Update a row entry in the table

The code snippet updates the Telephone number associated with an entry in the Contacts table with FirstName = “Foo” to “555-7777”

Delete a row entry from the table

The code snippet deletes an entry in the Contacts table with FirstName = “Foo” .

Closing connection to the database

The following code snippet closes the connection to the database. All resources must have been “finalized” before you invoke this routine.


You can use the freely available plugin “SQLite Manager” (https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/) for Mozilla Firefox to examine/verify the contents of your sqlite database.