To get a count of how many texts in your inbox from each sender, you can use a SQL Group By clause. This is the popular trick to sneak a Group By clause into a ContentProvider:
Cursor cursor = getContentResolver().query(
Uri.parse("content://sms/inbox/"),
new String[] { "_id", "address", "count(*) as totals" },
"1) Group By (address",
null,
null);
However this does not work for Android 4.0+. (For me designing ContentProviders without a Group By clause is like manufacturing a keyboard without numbers...) For 4.0+, I would suggest iterating through the regular cursor and sorting the messages yourself.