I'm currently querying the Android sms/mms
database to retrieve all MMS
messages received and sent. Everything works fine, but I noticed that the column m_size only has a value for MMS
messages that were sent (not received).
Here's the query:
final String[] projection = new String[]{ "*" };
Uri uri = Uri.parse("content://mms");
Cursor query = _activity.getContentResolver().query(uri, projection, null, null, null);
using this, I am able to retrieve the total bytes of the message, but it is currently returning null
for MMS messages that were received.
if (query.moveToFirst())
{
do
{
// ...
Integer size = query.getInt(query.getColumnIndex("m_size"));
}
while (query.moveToNext());
}
Without having to calculate the "data"
column size of the message, is there anything wrong with my query/any reason why m_size
will return null
for MMS
messages that were received (and have a valid image attachment)?
Note: Not sure if anything has changed in earlier APIs, since this API is un-documented. I am currently testing/developing on a Nexus 5X using API 23.
From what I can see there's nothing wrong with your query.
There are a few reasons why m_size could be null. null is the default value of that column when the table is created, see MmsSmsDatabaseHelper. The default SMS app likely calls PduPersister.persist when saving the PDUs, and the message size is inserted here. The fact that you have persisted retrieved PDUs but no m_size indicates that the header did not contain this value. If you have a rooted device you can verify the header contents with tcpdump and Wireshark. I'm assuming that the default SMS app persisted the PDU and parts correctly, but one thing you could check is the message type of the MMSs in the inbox. When retrieving MMS, you'll first get a NOTIFICATION-IND that notifies that there's an MMS to download, and it contains some basic info. This should be persisted by the default app. It should then download the full MMS and persist a RETRIEVE-CONF. The message size is part of the NotificationInd. When the SMS app persists the RETRIEVE-CONF it may overwrite/delete the NOTIFICATION-IND, and m_size would be lost. To test this you could disable MMS auto download (if the app supports it), or just disable any data, as the notification will be delivered as a WAP Push message.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With