Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在一个查询中查找多个联系人电话_Android_Sqlite - Fatal编程技术网

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