Android中contentProvider的查询中的where子句 [英] where clause in contentProvider's query in Android

查看:55
本文介绍了Android中contentProvider的查询中的where子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to add functionality of contains() method in where clause. Right now I was doing something like "address = ?" and providing address in arguments but now I want to use a logic which works as address.contains(?) and then providing the address in arguments. How can I implement it? Till now my code is and need to know the require modification.

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中contentProvider的查询中的where子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆