使用由toArray()创建的数组的奇特/干净方式;

时间:2011-03-15 23:08:34

标签: android sqlite contacts

mids包含2个字符串:名称和ID。我想向我的IN子句收取ID。任何想法我怎么可能这样做而不迭代循环来构建以args形式输入的数组?

private List<Contacts> getCntctList(List<GroupMembers> mids){
    List<Contacts> cntcts = new ArrayList<Contacts>();
    ContentResolver cr = getContentResolver();
    Object[] mIDs = mids.toArray();
    Cursor contactCur = cr.query(People.CONTENT_URI, null, "People._ID IN (?)", new String [] { mIDs.toString() } , People.NAME + " ASC");
    if (contactCur.getCount() > 0) {
        while (contactCur.moveToNext()) {
           ...
        }
    }
    return cntcts;
}

0 个答案:

没有答案