【问题标题】:android query for phone number without formatandroid查询没有格式的电话号码
【发布时间】:2012-02-21 09:19:40
【问题描述】:

我正在尝试获取所有以某个查询开头的号码的联系人。

contactLookup = getContentResolver().query(
                Data.CONTENT_URI,
            new String[] { Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL },
            Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "' and "
                    + ContactsContract.CommonDataKinds.Phone.NUMBER + " like ?",
            new String[] { "%" + query + "%" }, null);

if (contactLookup != null && contactLookup.getCount() > 0) { 
   contactLookup.moveToNext();
   String number = contactLookup.getString(contactLookup.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
   Log.v("debug", number);
   contactLookup.getString(contactLookup.getColumnIndex(BaseColumns._ID));
}

号码是 123-456-789 但我的查询字符串是 123456。如何只比较不带格式字符的数字。

【问题讨论】:

    标签: android android-contentprovider android-contacts


    【解决方案1】:

    查看 SDK 中 PhoneUtils 中的可用功能。

    【讨论】:

      猜你喜欢
      • 2016-05-04
      • 2013-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-17
      • 1970-01-01
      相关资源
      最近更新 更多