• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

retrieving specific data from the database based on a substring

diggs369

Lurker
how do i retrieve only specific contacts from the database based on a substring entered in an edittext? thanks for the help:)
 
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null,ContactsContract.Contacts.DISPLAY_NAME +" like ?" , new String[]{"'%a%'"}, ContactsContract.Contacts.DISPLAY_NAME + " ASC");

I wanted to retrieve only those contact names which contained some specified substring, in this case '%a%'. But this code above it is not returning a single contact name. can u please tell me what is wring with it. thanks for the help..
 
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null,ContactsContract.Contacts.DISPLAY_NAME +" like ?" , new String[]{"'%a%'"}, ContactsContract.Contacts.DISPLAY_NAME + " ASC");

I wanted to retrieve only those contact names which contained some specified substring, in this case '%a%'. But this code above it is not returning a single contact name. can u please tell me what is wring with it. thanks for the help..
 
Back
Top Bottom