连字符是在获得联系方式与部分电话号码的问题 [英] hyphens are an issue in getting contact details with a partial phone number
本文介绍了连字符是在获得联系方式与部分电话号码的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个函数来得到一个电话号码的一部分的所有联系人,在这里...
I have a function to get all contacts with part of a phone number, here...
Cursor c = getContentResolver().query(Data.CONTENT_URI,
new String[] {Data._ID, Phone.NUMBER},
Phone.NUMBER + " like ?",
new String[] {"%"+String.valueOf(phoneNumber) +"%"}, null);
while (c.moveToNext()) {
String id = c.getString(0);
String number = c.getString(1);
Log.d("id",id);
Log.d("number",number);
}
但问题是 - 如果我插入 31221
我不能得到一个电话号码,如联系人312-2131-321
- 或我,如果我插入 0558836298
我不能得到 62558836298 因为
的code>,因为
+
和国家code。
感谢您的帮助。
but the problem is - IF i insert 31221
I can't get contacts with a phone number like 312-2131-321
Because of "-"
or i if i insert 0558836298
i cant get +62558836298
because of "+"
and country code.
Thanks for the help
PS我不知道
Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
但只有当你把整个数量的作品。
but that works only if you put the whole number.
推荐答案
请尝试更换这样的:
Please try to replace this:
Phone.NUMBER
本:
"replace("+Phone.NUMBER+", '-','')"
它使用的SQLite从替换功能删除hypens。
It's using replace function from SQLite to remove hypens.
这篇关于连字符是在获得联系方式与部分电话号码的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文