我如何在Android中使用ContentResolver的不区分大小写的查询? [英] How do I make a case insensitive query with ContentResolver in Android?

查看:241
本文介绍了我如何在Android中使用ContentResolver的不区分大小写的查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是让从本地数据库中的所有行与Android的姜饼及以上特定的电子邮件地址。

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

我读过有关WHERE子句为sql其中一个使用较低的('XX'),但我想不出如何使用它。我也学会了你可以创建表时列不关心的情况下,但船舶航行。

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.

推荐答案

请试试(我想,邮箱是String对象):

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

Cursor cursor = context.getContentResolver().query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,
        new String[] {Contacts._ID}, "lower("+ContactsContract.CommonDataKinds.Email.ADDRESS + ")=lower('"+ email +"')",
        new String[] {}, null);

这篇关于我如何在Android中使用ContentResolver的不区分大小写的查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆