d:\test>adb shell $ su su # cd /data/data/com.android.providers.telephony/databases cd /data/data/com.android.providers.telephony/databases # ls ls firewall.db mmssms.db-wal telephony.db-shm mmssms.db msmsms.db telephony.db-wal mmssms.db-shm telephony.db traffic.db # sqlite3 mmssms.db sqlite3 mmssms.db SQLite version 3.7.2 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> .tables .tables addr pdu threads android_metadata pending_msgs words attachments rate words_content canonical_addresses raw words_segdir drm sms words_segments part sr_pending sqlite> .schema threads .schema threads CREATE TABLE threads ( _id INTEGER PRIMARY KEY, date INTEGER DEFAULT 0, server_date INTEGER DEFAULT 0, message_count INTEGER DEFAULT 0, unread_count INTEGER DEFAULT 0, photo_id TEXT, recipient_addresses TEXT, recipient_names TEXT, is_sp TEXT, person_id TEXT, recipient_ids TEXT, snippet TEXT,s nippet_cs INTEGER DEFAULT 0, read INTEGER DEFAULT 1, type INTEGER DEFAULT 0, error INTEGER DEFAULT 0, has_attachment INTEGER DEFAULT 0, state INTEGER DEFAULT 0); sqlite> .schema sms .schema sms CREATE TABLE sms ( _id INTEGER PRIMARY KEY, thread_id INTEGER, address TEXT, person INTEGER, date INTEGER, server_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, timed INTEGER DEFAULT 0);(这里需要注意的是查看/data/data目录下的文件需要有root权限)
// 读取收件箱中指定号码的短信 Cursor cursor = managedQuery(Uri.parse("content://sms/inbox"), new String[] { "_id", "address", "body", "read" }, " address=? and read=?", new String[] { "106597281", "0" }, "date desc"); if (cursor != null) { ContentValues values = new ContentValues(); values.put("read", "1"); // 修改短信为已读模式 cursor.moveToFirst(); if (cursor.moveToFirst()) { // 根据id修改短信的状态为已读状态 getContentResolver().update(Uri.parse("content://sms/inbox"), values, " _id=?", new String[] { "" + cursor.getInt(0) }); // 删除指定号码的短信 int smsId = cursor.getInt(0); String msgbody = cursor.getString(cursor.getColumnIndexOrThrow("body")); try { msgbody = (new String(msgbody.getBytes(), "utf8")).trim(); } catch (UnsupportedEncodingException e) { Log.e("TAG", "", e); } // 删除指定短信 getContentResolver().delete(Uri.parse("content://sms/" + smsId), null, null); } } cursor.close();