Friday, February 11, 2011

Contacts Contract: Intro and Getting Started

If you've been using Android awhile, and have used the Contacts feature at all, you may have noticed that when you push your SDK forward a few versions, many of the calls are now listed as deprecated.

This is because the Android project revamped how the contacts system works in Android 2.0 (API Level 5). The updated system is much more flexible, while also taking a bit more code to use properly. Over at Mobiletuts+, we wrote an article quite a while back that has a quick overview of using the new APIs in context of using the contact picker. Android Essentials: Using the Contact Picker demonstrates how the queries are now often broken up due to increase in the number of internal tables used (or, that's mostly likely the cause).

You can also directly view the open source code for this tutorial.

1 comment:

Wei Chong Tan said...

Hi,
I'm learning to use Intent(Intent.ACTION_PICK,Contacts.CONTENT_URI) and ContactsContract.Contact and I am able to read phone number of an account correctly to my EditText.
However, in the Contact Picker that it launches, only the non SIM contacts are shown. When I set my phone's Contact application's Display Option to only show SIM and disable others, my Contact Picker would not show even one contact.
Can you explain what is the difference?
Thanks.