Skip to content

Commit 12e7b65

Browse files
Fixed|Changed(SmsInboxAPI)!: Fix exception for message address/from selection and use exact match
SQL does not seem to consider `?` placeholders if inside quotes. ``` java.lang.IllegalArgumentException: Cannot bind argument at index 1 because the index is out of range. The statement has 0 parameters. at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142) at android.content.ContentProviderProxy.query(ContentProviderNative.java:472) at android.content.ContentResolver.query(ContentResolver.java:1183) at android.content.ContentResolver.query(ContentResolver.java:1115) at android.content.ContentResolver.query(ContentResolver.java:1071) at com.termux.api.apis.SmsInboxAPI.getAllSms(SmsInboxAPI.java:302) ``` Exact match is used by default so that only exactly matched entries are returned, users can use `%` wildcards in the address passed if they want to do prefix/contains/suffix matching. - https://www.w3schools.com/sql/sql_like.asp
1 parent 1b60b23 commit 12e7b65

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

app/src/main/java/com/termux/api/apis/SmsInboxAPI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public static void getAllSms(Context context, JsonWriter out,
292292
String[] messageSelectionArgs = null;
293293
if (messageSelection == null || messageSelection.isEmpty()) {
294294
if (messageAddress != null && !messageAddress.isEmpty()) {
295-
messageSelection = ADDRESS + " LIKE '%?%'";
295+
messageSelection = ADDRESS + " LIKE ?";
296296
messageSelectionArgs = new String[]{messageAddress};
297297
}
298298
}

0 commit comments

Comments
 (0)