3

I am using "content://mms" Content resolver and getting mms database. How to get number,sent/received, body and attachment details from that?

Kruti Mevada
  • 517
  • 5
  • 7
  • 21
  • "I am using "content://mms" Content resolver and getting mms database." -- that is not part of Android. That is part of an application that may or may not be on any given Android device. Furthermore, it is undocumented and unsupported, and so may be removed or altered at any point in time. – CommonsWare Nov 20 '10 at 15:58
  • then how to access sms and mms data in android? – Kruti Mevada Nov 22 '10 at 05:36
  • i want all the mms and sms details for my aplication – Kruti Mevada Nov 22 '10 at 05:37

1 Answers1

0

This link actually helped me a lot:

Try this post: How to Read MMS Data in Android?

Hope this helps you little bit..:)

I also tried to get some info by using this code:

private String getMmsText(String id) {
        Uri partURI = Uri.parse("content://mms/part/" + id);
        InputStream is = null;
        StringBuilder sb = new StringBuilder();
        try {
            is = getContentResolver().openInputStream(partURI);
            if (is != null) {
                InputStreamReader isr = new InputStreamReader(is, "UTF-8");
                BufferedReader reader = new BufferedReader(isr);
                String temp = reader.readLine();
                while (temp != null) {
                    sb.append(temp);
                    temp = reader.readLine();
                }
            }
        } catch (IOException e) {
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (IOException e) {
                }
            }
        }
        return sb.toString();
    }

// Main Text
        Cursor cursor = getContentResolver().query(uri, null, selectionPart,
                null, null);
        if (cursor.moveToFirst()) {
            do {
                String partId = cursor.getString(cursor.getColumnIndex("_id"));
                String type = cursor.getString(cursor.getColumnIndex("ct"));
                if ("text/plain".equals(type)) {
                    String data = cursor.getString(cursor
                            .getColumnIndex("_data"));

                    if (data != null) {
                        // implementation of this method below
                        body = getMmsText(partId);
                    } else {
                        body = cursor.getString(cursor.getColumnIndex("text"));
                    }
                }
            } while (cursor.moveToNext());

        }
        cursor.close();
Community
  • 1
  • 1
mike20132013
  • 5,357
  • 3
  • 31
  • 41