2

The explanation of the Android messaging database in this post How to Read MMS Data in Android? have been very helpful. Unfortunately I do not have enough reputation to ask for a clarification there. I need to get the time an MMS message was sent. Is this available through the database? If not, is it saved anywhere else? Getting the sent time from the the phone on the sending end would also work.

Edit: I see now that the DATE_SENT attribute is available but I don't know how to access it. Is there a provider for this like there is for the address?

Update: This is what my code looks like:

int id = 0;
ContentResolver contentResolver = getContentResolver();
final String[] projection = new String[]{"*"};
Uri uri = Uri.parse("content://mms-sms/conversations/");
Cursor query = contentResolver.query(uri, projection, null, null, null);
if (query.moveToFirst()) {
    do {
        String string = query.getString(query.getColumnIndex("ct_t"));
        if ("application/vnd.wap.multipart.related".equals(string)) {
            //MMS
            System.out.println("b:mms found");
            System.out.println("b:thing in table is " + query.getString(query.getColumnIndex("_id")));
            id = Integer.parseInt(query.getString(query.getColumnIndex("_id")));
            System.out.println("b:" + getAddressNumber(id));
        } else {
            //SMS
            System.out.println("b:sms found");
        }
    } while (query.moveToNext());
}

It works for column index of _id and date but not date_sent.

Community
  • 1
  • 1
user1959417
  • 224
  • 2
  • 8
  • *Unfortunately I do not have enough reputation to ask for a clarification there.*, you do! Add a comment to the appropriate answerer's section on that page. As for SMS/MMS, it is not official nor documented, and likely to be dropped at some stage, read, *undocumented* and relying on that could break your app in the future. – t0mm13b Jan 23 '13 at 19:51
  • 1
    I'm pretty sure you need 50 reputation to comment on other people's answers to other people's questions. – user1959417 Jan 23 '13 at 19:53
  • Then upvote other questions, improve answers, suggest edits... to bump up your rep. Get involved! – t0mm13b Jan 23 '13 at 19:55
  • For your benefit - I have upvoted yours, now go and upvote others... – t0mm13b Jan 23 '13 at 20:02

1 Answers1

2

Yes the date is in one of the databases but since it is not documented and unsupported it could and probably will change over time. you are going to have to go through the source code to see how to access is.

http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.1.1_r1/android/provider/Telephony.java?av=f

I have dealt with the mms provider and it is not fun having it undocumented and different across devices

tyczj
  • 71,600
  • 54
  • 194
  • 296