How to use SMS content provider? Where are the docs?

In addition to those u can see the list of fields in sms content provider by using following code:

private void displaySmsLog() {
    Uri allMessages = Uri.parse("content://sms/");
     //Cursor cursor = managedQuery(allMessages, null, null, null, null); Both are same
    Cursor cursor = this.getContentResolver().query(allMessages, null,
            null, null, null);

    while (cursor.moveToNext()) {
        for (int i = 0; i < cursor.getColumnCount(); i++) {
            Log.d(cursor.getColumnName(i) + "", cursor.getString(i) + "");
        }
        Log.d("One row finished",
                "**************************************************");
    }

}

This is what I got from API 23:

public static final String COLUMN_ID = "_id";
public static final String COLUMN_THREAD_ID = "thread_id";
public static final String COLUMN_ADDRESS = "address";
public static final String COLUMN_PERSON = "person";
public static final String COLUMN_DATE = "date";
public static final String COLUMN_DATE_SENT = "date_sent";
public static final String COLUMN_PROTOCOL = "protocol";
public static final String COLUMN_READ = "read";
public static final String COLUMN_STATUS = "status";
public static final String COLUMN_TYPE = "type";
public static final String COLUMN_REPLY_PATH_PRESENT = "reply_path_present";
public static final String COLUMN_SUBJECT = "subject";
public static final String COLUMN_BODY = "body";
public static final String COLUMN_SERVICE_CENTER = "service_center";
public static final String COLUMN_LOCKED = "locked";
public static final String COLUMN_ERROR_CODE = "error_code";
public static final String COLUMN_SEEN = "seen";
public static final String COLUMN_TIMED = "timed";
public static final String COLUMN_DELETED = "deleted";
public static final String COLUMN_SYNC_STATE = "sync_state";
public static final String COLUMN_MARKER = "marker";
public static final String COLUMN_SOURCE = "source";
public static final String COLUMN_BIND_ID = "bind_id";
public static final String COLUMN_MX_STATUS = "mx_status";
public static final String COLUMN_MX_ID = "mx_id";
public static final String COLUMN_OUT_TIME = "out_time";
public static final String COLUMN_ACCOUNT = "account";
public static final String COLUMN_SIM_ID = "sim_id";
public static final String COLUMN_BLOCK_TYPE = "block_type";
public static final String COLUMN_ADVANCED_SEEN = "advanced_seen";
public static final String COLUMN_B2C_TTL = "b2c_ttl";
public static final String COLUMN_B2C_NUMBERS = "b2c_numbers";
public static final String COLUMN_FAKE_CELL_TYPE = "fake_cell_type";
public static final String COLUMN_URL_RISKY_TYPE = "url_risky_type";

And this is how I print all the contents:

    private void readAllMessages() {
    List<Sms> smssList = new ArrayList<Sms>();
    Sms sms;
    Cursor cursor = getContentResolver().query(Uri.parse("content://sms/inbox"), null, null, null, null);
    if (cursor.moveToFirst()) {
        String message = "";
        do {
            sms = new Sms();
            sms.set_id(cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_ID)));
            sms.setThreadId(cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_THREAD_ID)));
            sms.setAddress(cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_ADDRESS)));
            sms.setPerson((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_PERSON))));
            sms.setDate((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_DATE))));
            sms.setDateSent((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_DATE_SENT))));
            sms.setProtocol((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_PROTOCOL))));
            sms.setRead((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_READ))));
            sms.setStatus((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_STATUS))));
            sms.setType((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_TYPE))));
            sms.setReplyPathPresent((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_REPLY_PATH_PRESENT))));
            sms.setSubject((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_SUBJECT))));
            sms.setBody((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_BODY))));
            sms.setServiceCenter((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_SERVICE_CENTER))));
            sms.setLocked((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_LOCKED))));
            sms.setErrorCode((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_ERROR_CODE))));
            sms.setSeen((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_SEEN))));
            sms.setTimed((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_TIMED))));
            sms.setDeleted((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_DELETED))));
            sms.setSyncState((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_SYNC_STATE))));
            sms.setMarker((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_MARKER))));
            sms.setSource((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_SOURCE))));
            sms.setBindId((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_BIND_ID))));
            sms.setMxStatus((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_MX_STATUS))));
            sms.setMxId((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_MX_ID))));
            sms.setOutTime((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_OUT_TIME))));
            sms.setAccount((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_ACCOUNT))));
            sms.setSimId((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_SIM_ID))));
            sms.setBlockType((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_BLOCK_TYPE))));
            sms.setAdvancedSeen((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_ADVANCED_SEEN))));
            sms.setB2cTtl((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_B2C_TTL))));
            sms.setB2cNumbers((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_B2C_NUMBERS))));
            sms.setFakeCellType((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_FAKE_CELL_TYPE))));
            sms.setUrlRiskyType((cursor.getString(cursor.getColumnIndexOrThrow(Sms.COLUMN_URL_RISKY_TYPE))));

            Log.v(TAG, "SMS read " + sms);
            smssList.add(sms);
        } while (cursor.moveToNext());
    } else {
        Log.v(TAG, "The user does not have any sms");
    }
}

The source code could be found here: https://github.com/jiahaoliuliu/Akami/tree/feature/allSmsFields


Unfortunately the content provider for Sms and Mms (android.providers.Telephony) is not part of the public API at this moment. Until it is, you can define your own constants using this as a template.


You can take a look a the new API 19 : https://developer.android.com/reference/android/provider/Telephony.TextBasedSmsColumns.html https://developer.android.com/reference/android/provider/Telephony.Sms.html