Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.util.Log; public class Main { public static String LOG_TAG = "SmsNoMore"; public static int getSmsCount(Context context) { try { int result = 0; Cursor c = context.getContentResolver().query(Uri.parse("content://sms/inbox"), new String[] { "count(_id)", }, null, null, null); if (c.moveToFirst()) { result = c.getInt(0); } c.close(); return result; } catch (Throwable t) { LOGE("getSmsCount: " + t.getMessage()); t.printStackTrace(); } return 0; } public static void LOGE(final String text) { Log.e(LOG_TAG, text); } }