aneela
aneela

Reputation: 1619

where clause in contentProvider's query in Android

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

Upvotes: 6

Views: 8521

Answers (1)

bakriOnFire
bakriOnFire

Reputation: 2681

Try this

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

Upvotes: 14

Related Questions