0

I am implementing the method discussed here How to Read MMS Data in Android. Here is the code snippet:

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);

When I try to get the data through the cursor, I do not get the IDs of the MMS messages. I only get the IDs of the SMS messages.

Community
  • 1
  • 1
yasserbn
  • 391
  • 3
  • 18
  • This is likely to fail in Samsung devices like Galaxy S3 with a NullPointerException from the ContentProvider :( Only solution for that was to change the URI to "content://mms-sms/conversations/?simple=true" – Adrien Aubel Jan 29 '15 at 19:50

2 Answers2

0

change your code as:

ContentResolver contentResolver = getContentResolver();

final String[] projection = new String[]{"*"};

Uri MMSSMS_FULL_CONVERSATION_URI = Uri.parse("content://mms-sms/conversations");  

Uri uri  = MMSSMS_FULL_CONVERSATION_URI.buildUpon().  
     appendQueryParameter("simple", "true").build(); 

Cursor query = contentResolver.query(uri, projection, null, null, null);
ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213
0

My code is right. It just needs this code to get the id of the messages

cursor.moveToFirst();
String address = cursor.getString(cursor.getColumnIndex("_id"));
yasserbn
  • 391
  • 3
  • 18