Android 在一个查询中查找多个联系人电话
是否可以在单个查询中使用电话号码列表搜索联系人信息(姓名、照片)?例如:Android 在一个查询中查找多个联系人电话,android,sqlite,Android,Sqlite,是否可以在单个查询中使用电话号码列表搜索联系人信息(姓名、照片)?例如: SELECT name, photo FROM contacts WHERE phonenumber IN ("0123456", "987812", "365463") 目前,我通过许多查询在一个循环中检索联系人信息,但速度非常慢: String[] phonenumbers = new String[]{"03012345", "04012345", "089012551"}; String[] projection
SELECT name, photo
FROM contacts
WHERE phonenumber IN ("0123456", "987812", "365463")
目前,我通过许多查询在一个循环中检索联系人信息,但速度非常慢:
String[] phonenumbers = new String[]{"03012345", "04012345", "089012551"};
String[] projection = new String[]{PhoneLookup.DISPLAY_NAME, PhoneLookup._ID};
for (int i = 0; i < phonenumbers.length; i++) {
// Retrieve name and contact id
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, phonenumbers[i]);
Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
String name = cursor.getString(cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME));
long id = cursor.getLong(cursor.getColumnIndex(PhoneLookup._ID));
// retrieve photo bitmap with contact id
uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, id);
InputStream input = ContactsContract.Contacts.openContactPhotoInputStream(getContentResolver(), uri);
Bitmap photo = BitmapFactory.decodeStream(input);
}
String[]phonenumbers=新字符串[]{“03012345”、“04012345”、“089012551”};
字符串[]投影=新字符串[]{PhoneLookup.DISPLAY\u NAME,PhoneLookup.\u ID};
for(int i=0;i