I have these codes which basically use a ListView to display the names in the contact list and I want to get their phone number when click each single name:
it returns -1 because you don't request the column ContactsContract.CommonDataKinds.Phone.NUMBER from DB:
new String[] {ContactsContract.Contacts.DISPLAY_NAME}
ContactsContract.Contacts.DISPLAY_NAME is the only field you request.
To be able to get the phone number, you firstly need to include it into list of columns you want to get from DB:
new String[] {ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER}
Now you have to override adapter's getView so it sets the name into the textView of the list row. After that your onItemClick will work as expected