android - Android 中 contentProvider 查询中的 where 子句

标签 android where

我想在 where 子句中添加 contains() 方法的功能。现在我正在做类似 "address = ?" 的事情,并在参数中提供地址,但现在我想使用一个作为 address.contains(?) 的逻辑,然后在参数中提供地址。我该如何实现? 到目前为止,我的代码是并且需要知道需要修改。

Uri mSmsinboxQueryUri = Uri.parse("content://sms");
        String[] projection = new String[] { "_id", "thread_id", "address",
                "person", "date", "body", "type" };

        Cursor cursor1 = getContentResolver().query(mSmsinboxQueryUri,
                projection, "address = ?", new String[]{addressToBeSearched}, null);

最佳答案

试试这个

Cursor cursor1 = getContentResolver().query(mSmsinboxQueryUri,
                projection, "address LIKE ?", new String[]{addressToBeSearched + "%" }, null);

关于android - Android 中 contentProvider 查询中的 where 子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16771636/

相关文章:

android - 哪个 Android 虚拟设备 (AVD) 更快?

android - 旧值在 For each 循环中重复

sqlite - 正确的 SQLite 语法 - UPDATE SELECT with WHERE EXISTS

MySQL : IS NOT NULL check on custom generated column(alias)

javascript - "where in"nodejs中的MySQL查询

android - 在 webview 外部单击时防止 WebView 关闭

android - 为什么我的代码不能在网络中的 react native 代码中运行

sql - WHERE 子句中的 If..Else 或 Case - 一些不同的东西

java - libgdx 中的流 API

MySQL 查询 WHERE 包括 CASE 还是 IF?