android 设置所有短信为已读

private void setAllMessageRead(ContentResolver cr) {
    Uri SMS_INBOX = Uri.parse("content://sms/");
    String[] projection = new String[]{"_id", "address", "date", "read"};
    Cursor cursor = cr.query(SMS_INBOX, projection, null, null, "date desc");
    if (null == cursor) {
        return;
    }
    String read = null;
    String id = null;
    ContentValues values = new ContentValues();
    values.put("read", "1");
    while (cursor.moveToNext()) {
        read = cursor.getString(cursor.getColumnIndex("read"));
        id = cursor.getString(cursor.getColumnIndex("_id"));
        //Log.d("MAX", "autoDeleteNotiMessage id:" + id + ",read:" + read);
        if (read.equals("0")) {
            cr.update(Uri.parse("content://sms/"), values, "_id=?", new String[]{id});
            Log.d("MAX", "autoDeleteNotiMessage id:" + id);
        }
    }
    cursor.close();
}

你可能感兴趣的:(MMS)