Telephone

Read text messages (sms)

    public static void ReadSms(Context context) {
        Uri sms_content = Uri.parse("content://sms");
        Cursor cursor = context.getContentResolver().query(sms_content, null,null, null, null);
        cursor.moveToFirst();
        while (cursor.moveToNext()) {
            Date smsDate = new Date(cursor.getLong(4)); // date
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Log.d(TAG, sdf.format(smsDate));
            Log.d(TAG, cursor.getString(12));  // body
        }
    }
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License