get contacts performance issue

Solution 1:

You can get name and ID at the same time you get the phone number:

String[] PROJECTION=new String[] {Contacts._ID, Contacts.DISPLAY_NAME, Phone.NUMBER};
Cursor pCur = cr.query(Phone.CONTENT_URI, PROJECTION, Phone.CONTACT_ID +" = ?",
                                      new String[]{id}, null);

This eliminates the per-row sub-query.

Solution 2:

Using a Cursor is a great approach for this problem. To get retrieve information from a specific position, you can use Cursor.moveToPosition(int position). Then you can access any field of the Cursor, in this case a String, using Cursor.getString(int columnIndex).

Take a look at the Cursor documentation for more details.

The best part about this approach is that you can implement a CursorLoader to do the background data retrieval for you. It also automatically handles repopulating your ListView on data changes, orientation changes, etc. Check out this great tutorial for more explanation.