where clause in contentProvider's query in Android

梦想的初衷 提交于 2021-02-07 03:20:03

问题


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);

回答1:


Try this

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


来源:https://stackoverflow.com/questions/16771636/where-clause-in-contentproviders-query-in-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!