Tag:android sms unread SMS
Package Com.example.missedcall;import Android.content.context;import Android.database.cursor;import Android.net.uri;import Android.provider.calllog;import android.provider.calllog.calls;/** * Do not like to write blog, directly on the code, Note The Content section refers to the material on the Web * * First post the relevant protocol: Content://sms/inbox Inbox Content://sms/sent sent Content://sms/draft Draft content://sms/outbox Outbox content://sms/failed send failed content://sms/queued to send list Outbox no query to data on simulator , found on the simulator long time also did not find the Outbox, very depressed. The SMS related fields in the database are as follows: _id a self-increment field, starting from 1 thread_id serial number, same Sender ID same address sender mobile number person contact list number, MO Null Date Sender Date protocol protocol, divided into: 0 sms_rpoto, 1 mms_proto read whether reading 0 unread, 1 read status State-1 Receive, 0 complete, pending, failed type all = 0; INBOX = 1; SENT = 2; DRAFT = 3; OUTBOX = 4; FAILED = 5; QUEUED = 6; Body SMS Content service_center SMS Service center number subject SMS theme Reply_path_present TP-REPLY-path Locked * * * */public class Misscall {/** * Read missed phone number * */public static int Readmisscall (context context) { int result = 0; cursor cursor = context.getcontentresolver (). Query (CallLog.Calls.CONTENT_URI, new string[] {Calls.type }, "Type=?" And new=? ", new string[] {calls.missed_type +" "," 1 "}," date desc "); if (cursor! = NULL) {result = Cursor.getcount (); Cursor.close (); } return result; }/** * Get unread MMS number * */public static int Getnewmmscount (context context) {int result = 0; Cursor CSR = Context.getcontentresolver (). Query (Uri.parse ("Content://mms/inbox"), NULL, "read = 0", NULL, n ULL); if (CSR! = null) {result = Csr.getcount (); Csr.close (); } return result; }/** * Get unread SMS number * */public static int Getnewsmscount (context context) {int result = 0; Cursor CSR = context.getcOntentresolver (). Query (Uri.parse ("content://sms"), NULL, "type = 1 and read = 0", null, NULL); if (CSR! = null) {result = Csr.getcount (); Csr.close (); } return result; }}
Get unread information