Android Read recent SMS messages from command line I have recently broken my Android's screen. (Again) 

Its a T-Mobile G2

Trying to keep up with my busy technology related life is hard enough without losing my link with everyone.

I have rooted the phone and have the USB Debugging already turned on. 

Does anyone know how I would check my recent SMS Messaged from the adb shell so I can keep up with work while i save up to get a new phone or a replacement screen.

Thanks for anyone that has any information regarding this.

EDIT

Response to eldarerathis

C:\android-sdk\platform-tools&gt;adb shell
$ cd /data/data/com.android.providers.telephony/databases
cd /data/data/com.android.providers.telephony/databases
$ sqlite3 mmssms.db
sqlite3 mmssms.db
sqlite3: permission denied
$


cant chmod the file.
do you know actually where it is ?

$ chmod +x sqlite3
chmod +x sqlite3
Bad mode
$


su leaves me with only basic commands

$ su
su
# cd /data/data/com.android.providers.telephony/databases
cd /data/data/com.android.providers.telephony/databases
# sqlite3 mmssms.db
sqlite3 mmssms.db
sqlite3: not found
#


Corrected

sqlite was not installed

C:\android-sdk\platform-tools&gt;adb shell
$ cd /data/data/com.android.providers.telephony/databases
cd /data/data/com.android.providers.telephony/databases
$ sqlite3 mmssms.db
sqlite3 mmssms.db
SQLite version 3.6.22
Enter ".help" for instructions
sqlite&gt;


Also to Access the database I needed to be root.

C:\android-sdk\platform-tools&gt;adb shell
$ su
# cd /data/data/com.android.providers.telephony/databases
cd /data/data/com.android.providers.telephony/databases
# sqlite3 mmssms.db
sqlite3 mmssms.db
SQLite version 3.6.22
Enter ".help" for instructions
sqlite&gt;


Thanks a lot eldarerathis

This Link Helped
This is really ugly, but you can read them from the command line by using sqlite3 to view the database entries. You'll probably need to dig up a binary for this unless you have a custom ROM installed. There are some instructions for installing said binary in this Stack Overflow question, and SuperOneClick comes packaged with it (a copy of the binary itself can be found here).

If you do need to install the binary, use mount (with no parameters) to determine where your /system partition is physically located (mine is /dev/block/mtdblock3, for example). Then follow the instructions in the first link above, and start by remounting it in read/write mode with the command:

mount -o rw,remount /your/system/partition /system


Once you have sqlite3 you'll want to open an adb shell, switch to root with su, and then do the following:

# cd /data/data
cd /data/data
# cd com.android.providers.telephony/databases ***
cd com.android.providers.telephony/databases
# sqlite3 mmssms.db
sqlite3 mmssms.db
SQLite version 3.7.2
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite&gt; SELECT * FROM sms WHERE read=0;


This will pull up all of the rows from the table for all of the unread messages. The columns in the table are defined thusly (so you can trim the SELECT):

CREATE TABLE sms (_id INTEGER PRIMARY KEY,thread_id INTEGER,address TEXT,
  person INTEGER,date INTEGER,protocol INTEGER,read INTEGER DEFAULT 0,
  status INTEGER DEFAULT -1,type INTEGER,reply_path_present INTEGER,
  subject TEXT,body TEXT,service_center TEXT,locked INTEGER DEFAULT 0,
  error_code INTEGER DEFAULT 0,seen INTEGER DEFAULT 0);


***Note for the marked line: this may be slightly different depending on your device and version of Android which is why I have included this cd command separately. I think it used to be com.android.providers/telephony/databases on older devices but I don't quite remember. Use ls to look around for the proper pathing here.



Alternatively, you could try copying the .db file onto your SD card (or pulling it with adb pull) and then reading it on your computer with sqlite.