To get phone contacts ,we use
Cursor c = getContentResolver().query(uri, projection, selection, selectionArgs, sortOrder)
We have to put an uri for getting contacts.
full code
protected void pickContact() {
//startActivityForResult(new Intent(Intent.ACTION_PICK, People.CONTENT_URI), 0);
Cursor cursor = getContentResolver().query(People.CONTENT_URI, null, null, null, null);
startManagingCursor(cursor);
// start mappings
String[] columns = new String[] {People.NAME, People.NUMBER};
int[] names = new int[] {R.id.phone1};
myAdapter = new SimpleCursorAdapter(this, R.layout.phonecontacts, cursor, columns, names);
list.setAdapter(myAdapter);
}
Cursor c = getContentResolver().query(uri, projection, selection, selectionArgs, sortOrder)
We have to put an uri for getting contacts.
full code
protected void pickContact() {
//startActivityForResult(new Intent(Intent.ACTION_PICK, People.CONTENT_URI), 0);
Cursor cursor = getContentResolver().query(People.CONTENT_URI, null, null, null, null);
startManagingCursor(cursor);
// start mappings
String[] columns = new String[] {People.NAME, People.NUMBER};
int[] names = new int[] {R.id.phone1};
myAdapter = new SimpleCursorAdapter(this, R.layout.phonecontacts, cursor, columns, names);
list.setAdapter(myAdapter);
}
0 comments: