My goal is to get all rows from native db with a specific email address on Android Gingerbread and above.
This query gets only the rows where the case also matches.
Cursor cursor = context.getContentResolver().query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,
new String[] {Contacts._ID}, ContactsContract.CommonDataKinds.Email.ADDRESS + "=?",
new String[] {email}, null);
I've read about WHERE clauses to sql where one use lower('xx') but I can't figure out how to use it. Also I learned to you can make the column not care about case when creating the table, but that ship has sailed.
Also try
Cursor cursor = context.getContentResolver().query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,
new String[] {Contacts._ID}, ContactsContract.CommonDataKinds.Email.ADDRESS + "=? COLLATE NOCASE",
new String[] {email}, null);
Note that added COLLATE NOCASE
in the query.
Please try (I suppose that mail is String object):
Cursor cursor = context.getContentResolver().query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,
new String[] {Contacts._ID}, "lower("+ContactsContract.CommonDataKinds.Email.ADDRESS + ")=lower('"+ email +"')",
null, null);
or
Cursor cursor = context.getContentResolver().query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,
new String[] {Contacts._ID}, "lower("+ContactsContract.CommonDataKinds.Email.ADDRESS + ")=lower('"+ email +"')",
new String[] {}, null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With