Rabu, 31 Oktober 2018

SQLLite Android like %%


Akan salah jika :
android.database.sqlite.SQLiteException: near "%": 
syntax error: , while compiling: 
SELECT ... FROM ... 
WHERE ((display_name like %?%)) 
ORDER BY display_name ASC
SOLUSINYA:
Cursor contactsContractContacts = resolver.query(
    ContactsContract.Contacts.CONTENT_URI, projection,
    ContactsContract.Contacts.DISPLAY_NAME + " like ?",
    new String[]{"%" + filterStr + "%"},
    ContactsContract.Contacts.DISPLAY_NAME + " ASC");

Tidak ada komentar:

Posting Komentar