Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Tom Finet
Tom Finet
7,027 Points

How to retrieve a list of contacts in android?

In my android app I wish to retrieve a list of the users contacts directly from my app and display it in a list. I have found some tutorials but they do not make things very clear to me. For example I still don not understand if this should be done in a separate thread or not.

In conclusion, can anyone provide me with a working example of how to retrieve the users contacts in android and explain to me wether or not this should be done in a background thread.

Thanks,

Happy coding guys!

1 Answer

Kourosh Raeen
Kourosh Raeen
23,733 Points

I'm not sure if you've read these pages or not but here they are:

https://developer.android.com/training/contacts-provider/retrieve-names.html https://guides.codepath.com/android/Loading-Contacts-with-Content-Providers

They are using a CursorLoader which handles the background thread creation automatically.

Tom Finet
Tom Finet
7,027 Points

Thanks thats all I needed! =)

Kourosh Raeen
Kourosh Raeen
23,733 Points

Awesome! Good luck coding your app!

Tom Finet
Tom Finet
7,027 Points

Thanks man! Good luck to you too!