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; import java.util.ArrayList; public class Main { public static String LOG_TAG = "SmsNoMore"; public static ArrayList<String> findSmsByAddress(Context context, String address) { ArrayList<String> list = new ArrayList<String>(); try { Cursor c = context.getContentResolver().query(Uri.parse("content://sms/inbox"), new String[] { "_id", "address" }, "address = ?", new String[] { address }, null); if (!c.moveToFirst() || c.getCount() == 0) { LOGI("there are no more messages"); c.close(); return list; } do { list.add(c.getString(0)); } while (c.moveToNext()); c.close(); } catch (Exception e) { LOGE("findSmsByAddress: " + e.getMessage()); } return list; } public static void LOGI(final String text) { Log.i(LOG_TAG, text); } public static void LOGE(final String text) { Log.e(LOG_TAG, text); } }