ArrayList<String> contactlist = new ArrayList<String>(); ArrayAdapter<String> adapter; ListView listView_contentProvider; // 适配器的定义 adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, contactlist); listView_contentProvider.setAdapter(adapter); listView_contentProvider .setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub Toast.makeText(ContentProviderActivity.this, arg2 + "", Toast.LENGTH_SHORT).show(); } }); readContact();// contactlist的初始化 // 构建练习人集合 private void readContact() { contactlist.clear(); Cursor cursor = null; // 读取系统暴露出来的URI ContentResolver contentResolver = getContentResolver(); try { // 用于查询指定Uri的ContentProvider。 cursor = contentResolver.query( ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null); while (cursor.moveToNext()) { String dis_name = cursor .getString(cursor .getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); int phone_index = cursor .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER); String dis_phone = cursor.getString(phone_index); contactlist.add(dis_name + " | " + dis_phone); } } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } finally { if (cursor != null) { cursor.close(); } } }