Search code examples
androidmms

MMS conversations recipient_ids column doesn't exist


My SMS-MMS code is reading conversations with the following code. From what I've read on other posts, this is the correct code for obtaining the MMS recipient_ids column. However, I get an error stating the column doesn't exist. What could be going wrong?"

ContentResolver resolver = context.getContentResolver();
Uri uri = Uri.parse("content://mms-sms/conversations?simple=true/");
String[] projection = new String[]{"*"};
String order = "date desc";

Cursor cursor = resolver.query (uri, projection, null, null, order);
while (cursor.moveToNext())
{
  long id = cursor.getLong (cursor.getColumnIndex ("_id"));
  long threadId = cursor.getLong (cursor.getColumnIndex ("thread_id"));
  String recips = cursor.getString (cursor.getColumnIndex ("recipient_ids"));
  ...
}

I'm building with minSdkVersion="19" and targetSdkVersion="19". I'm testing on a LG G2 running Android 4.4.2. At the moment, I haven't been able to test on any other phones.


Solution

  • The problem is the "/" at the end of the URI. Without it, the query works! A better way is to use the Uri.Builder, which would have avoided this problem. I'll admit, I often use the string form while experimenting because it's quicker - except in this case :)