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.


Response to eldarerathis

C:\android-sdk\platform-tools>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
# 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


sqlite was not installed

C:\android-sdk\platform-tools>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

Also to Access the database I needed to be root.

C:\android-sdk\platform-tools>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

Thanks a lot eldarerathis

This Link Helped

migrated from stackoverflow.com Jul 20 '11 at 11:36

This question came from our site for professional and enthusiast programmers.

  • It looks like you don't have the sqlite3 binary on your device. The first link in my answer has instructions to help you install it to /system/bin. Here is a link to the binary itself. – eldarerathis Jul 18 '11 at 19:47

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> 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):

  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,

***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.

  • I tried this and it seems that sqlite3 has permission denied – Jason Jul 18 '11 at 19:38
  • it says bad mode – Jason Jul 18 '11 at 19:42
  • @Jason: You need to be root to read that directory (just execute su beforehand). – eldarerathis Jul 18 '11 at 19:42
  • @Jason: Hm, use chmod 0755 sqlite3, then. Maybe the stock chmod binary doesn't like the +x parameter. – eldarerathis Jul 18 '11 at 19:43
  • as soon as I execute su. it acts like there are no commands – Jason Jul 18 '11 at 19:44

Thanks to the beautiful hint above from eldarerathis, I just do

echo 'select address,body from sms;' | ./sqlite3 -csv $DB 

to read my SMSes from my root prompt.

Since I didn't have sqlite3, I first had to download it with

curl http://dl.dropbox.com/u/16958605/sqlite3
chmod a+x sqlite3

Or see SQLite3 installer on Google Play (if you don't trust the dropbox source).

  • 1
    A dl.dropbox.com URL for that binary doesn't feel safe. Can you supply an official source? – pzkpfw Oct 26 '12 at 10:58

In case you're interested in more details than just sender and message (as in this answer), I've just found a nice article on the topic: Read SMS directly from Sqlite database in Android. Also see: The message data structure.

Even better, take a look at Github: ANDROID-SMS is a tool written in Python which recovers all SMS messages and organizes them into SMS Conversations with statistics provided. It also recovers all MMS messages and organizes them into MMS Conversations, with the respective files. I've not tried it (yet) myself (just found it a few minutes ago), but it sounds pretty neat.

Of course, this program doesn't work on the Android device directly – but instead on your computer (where it requires Python 2.7 with SQLite3 for Python). So you will need to first pull the database from the device. All required steps are described on the project's Github main page.


Another solution I invented utilizes an app on the phone that reacts on SMS and saves it to a file that you can read with ADB.

  • Install any Tasker-like app, I made it with E-Robot
  • Create new command
  • Add event Contact=>SMS
  • Add action Memory=>Write file, there you can save SMS to a new file every time or to the same one with separator. Anyway save it to /sdcard or any path accessible via ADB.
  • Monitor that path with ADB and read SMS contents.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.