Selecting SMS from given sender
<p>I was to try to retrieve SMS which matches the given sender name. I am using the following code</p>

<pre><code>Uri uriSMSURI = Uri.parse("content://sms/inbox");

    String where = "address like ?";
    String[] address = { "12345", "54321" };

    Cursor cursor = getContentResolver().query(uriSMSURI,
            new String[] { "_id", "address", "date", "body" }, where,
            address, null);
</code></pre>

<p>But its not working. I getting following error. Please help me with the query.</p>

<pre><code>&gt; 04-18 17:04:21.090: E/AndroidRuntime(483): FATAL EXCEPTION: main 04-18
&gt; 17:04:21.090: E/AndroidRuntime(483): java.lang.RuntimeException:
&gt; Unable to start activity
&gt; ComponentInfo{com.bebinary.smsdemo/com.bebinary.smsdemo.SMSQueryDemoActivity}:
&gt; android.database.sqlite.SQLiteException: bind or column index out of
&gt; range: handle 0x22bb28 04-18 17:04:21.090: E/AndroidRuntime(483):     at
&gt; android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
&gt; 04-18 17:04:21.090: E/AndroidRuntime(483):    at
&gt; android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
&gt; 04-18 17:04:21.090: E/AndroidRuntime(483):    at
&gt; android.app.ActivityThread.access$2300(ActivityThread.java:125) 04-18
&gt; 17:04:21.090: E/AndroidRuntime(483):  at
&gt; android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
&gt; 04-18 17:04:21.090: E/AndroidRuntime(483):    at
&gt; android.os.Handler.dispatchMessage(Handler.java:99) 04-18
&gt; 17:04:21.090: E/AndroidRuntime(483):  at
&gt; android.os.Looper.loop(Looper.java:123) 04-18 17:04:21.090:
&gt; E/AndroidRuntime(483):    at
&gt; android.app.ActivityThread.main(ActivityThread.java:4627) 04-18
&gt; 17:04:21.090: E/AndroidRuntime(483):  at
&gt; java.lang.reflect.Method.invokeNative(Native Method) 04-18
&gt; 17:04:21.090: E/AndroidRuntime(483):  at
&gt; java.lang.reflect.Method.invoke(Method.java:521) 04-18 17:04:21.090:
&gt; E/AndroidRuntime(483):    at
&gt; com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
&gt; 04-18 17:04:21.090: E/AndroidRuntime(483):    at
&gt; com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 04-18
&gt; 17:04:21.090: E/AndroidRuntime(483):  at
&gt; dalvik.system.NativeStart.main(Native Method) 04-18 17:04:21.090:
&gt; E/AndroidRuntime(483): Caused by:
&gt; android.database.sqlite.SQLiteException: bind or column index out of
&gt; range: handle 0x22bb28 04-18 17:04:21.090: E/AndroidRuntime(483):     at
&gt; android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:158)
&gt; 04-18 17:04:21.090: E/AndroidRuntime(483):    at
&gt; android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
&gt; 04-18 17:04:21.090: E/AndroidRuntime(483):    at
&gt; android.content.ContentProviderProxy.bulkQueryInternal(ContentProviderNative.java:330)
&gt; 04-18 17:04:21.090: E/AndroidRuntime(483):    at
&gt; android.content.ContentProviderProxy.query(ContentProviderNative.java:366)
&gt; 04-18 17:04:21.090: E/AndroidRuntime(483):    at
&gt; android.content.ContentResolver.query(ContentResolver.java:245) 04-18
&gt; 17:04:21.090: E/AndroidRuntime(483):  at
&gt; com.bebinary.smsdemo.SMSQueryDemoActivity.onCreate(SMSQueryDemoActivity.java:21)
&gt; 04-18 17:04:21.090: E/AndroidRuntime(483):    at
&gt; android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
&gt; 04-18 17:04:21.090: E/AndroidRuntime(483):    at
&gt; android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
</code></pre>
