0

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 .

user2569548
  • 41
  • 1
  • 1
  • 6

3 Answers3

1

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, e.g.:

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

ccbunney
  • 2,282
  • 4
  • 26
  • 42
1

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

Android_coder
  • 9,953
  • 3
  • 17
  • 23
0

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.

Community
  • 1
  • 1
grattmandu03
  • 1,266
  • 2
  • 13
  • 32