Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.database.Cursor; import android.net.Uri; public class Main { public static String getMessageCount(Context context, String id) { String res = null; try { final String[] projection = new String[] { "_id", "message_count" }; Uri uri = Uri.parse("content://mms-sms/conversations?simple=true"); Cursor query = context.getContentResolver().query(uri, projection, null, null, "date DESC"); if (query != null) { boolean find = false; while (query.moveToNext() && !find) { if (query.getString(query.getColumnIndex("_id")).equals(id)) { res = query.getString(query.getColumnIndex("message_count")); // Log.v("getMessageCount", "find, nb_sms = "+res); find = true; } } query.close(); } } catch (Exception e) { // Log.v("getMessageCount", "Erreur"); e.printStackTrace(); } return res; } }