I am a new developer . I am making app in which i want all Contacts in a listView . Contact name as main item and number as subitem . I do some but i can't to get all contact ( both from phone and sim ) .
How to get all contacts ?? how to set the name as main item and the number as subitem ??
please help . thanks in advance .
You need to query the ContactsContract
database using a contentResolver
. You can then use a SimpleCursorAdapter
to link this to your list view. There are quite a few examples of how to do this on the web if you search around, eg:
http://learnandroideasily.blogspot.co.uk/2013/03/how-to-access-contacts-in-android.html
Make sure you read up a bit on how the contacts are actually stored on Android as it is a slightly complicated 3-tier system:
http://developer.android.com/reference/android/provider/ContactsContract.html
Try this,
http://www.higherpass.com/Android/Tutorials/Working-With-Android-Contacts/
I hope this will help.. and if you need to store contact to listview.. first you store all values in arraylist
. and pass the arraylist
to adapter
. Then you display the contacts using listview
Do query on ContactsContract.Contacts.CONTENT_URI
like you can see here : get all contacts phone number . And do some research on Google from your own :).
For the ListView, search a tutorial to create a ListView.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.