Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where clause in contentProvider's query in Android

Tags:

android

where

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);
like image 889
aneela Avatar asked May 27 '13 10:05

aneela


1 Answers

Try this

Cursor cursor1 = getContentResolver().query(mSmsinboxQueryUri,
                projection, "address LIKE ?", new String[]{addressToBeSearched + "%" }, null);
like image 122
bakriOnFire Avatar answered Oct 29 '22 09:10

bakriOnFire