Programmatically Filter Items from a Cursor for simple_list_item_2
<p>I have an activity that reads two fields from a database and shows them in a List of simple_list_item_2. How can I filter the items returned by the cursor in java as the filtering cannot be done in SQL.</p>

<pre><code>import android.app.ListActivity;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.widget.SimpleCursorAdapter;

public class SMSReaderActivity extends ListActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Cursor cursor = getContentResolver().query(
                Uri.parse("content://sms/inbox"),
                new String[] { "_id", "date", "body" }, null, null, "date desc");
        startManagingCursor(cursor);

        SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this,
                android.R.layout.simple_list_item_2, cursor, new String[] {
                        "date", "body" }, new int[] { android.R.id.text1,
                        android.R.id.text2 });
        setListAdapter(mAdapter);
        }
}
</code></pre>

<p>Thank You,
Himanshu</p>
