Read Contacts From Device

 

This is a sample activity which shows How to read the contacts of phone and display them in your application. Last topic published on this forum is Detect USB connection.

Underlying Algorithm:

Basic description of algorithm in step by step form:
1.) Create a Project ReadContacts.
2.) Put the following code snippet in res/layout/main.xml :

 

 

 

3.) Add the following permission in AndroidManifest.xml :

 

 

 

4.) Import the following packages in activity:

 

 

 

5.) Add some contacts in device/emulator.
6.) Run the Application.

Steps to Create:

1.) Open Eclipse. Use the New Project Wizard and select Android Project Give the respective project name i.e. ReadContacts. Enter following information:
Project name: ReadContacts
Build Target: Android APIs2.1
Application name: ReadContacts
Package name: com.app. ReadContacts
Create Activity: ReadContacts

On Clicking Finish ReadContacts code structure is generated with the necessary Android Packages being imported along with ReadContacts.java. ReadContacts class will look like following:

 

 

 

Output –The final output:

Leave a Comment:

11 comments
Tyson F. Gautreaux says July 25, 2011

A SUPPORTED BY THE DEVELOPER TOOLS? It was interesting. You seem very knowledgeable in your field.

Reply
Nil says August 8, 2011

But how this will work on 1.5 or 1.6? Does Android SDK adjusts itself.

Reply
nakul says April 12, 2012

it is showing force close

wat the solution??????????????

Reply
Krunal Doshi says September 30, 2012

The method managedQuery(Uri, String[], String, String[], String) from the type Activity is deprecated

Reply
pissed says October 1, 2012

How can i loop and change all contacts accordingly… got +600 contacts, and providers here were so smart to add a new digit, but not providing a solution to change those numbers

Reply
Create a Toggle Button | I-Gadget says November 23, 2012

[…] This is a sample activity which shows How to create a Toggle Button in android. Last topic published on this forum is Read Contacts from device. […]

Reply
Create a Toggle Button | I-Gadget | Blog says December 9, 2012

[…] This is a sample activity which shows How to create a Toggle Button in android. Last topic published on this forum is Read Contacts from device. […]

Reply
Gobinath says February 3, 2013

yes its working, but i cant scroll the window after it displays all contacts. why?

Reply
krunal says May 7, 2013

nice tutorial

Reply
ash says May 31, 2013

can you please give us code for getting all contacts and all info of each contact

Reply
minahal says July 27, 2013

it is possible to display phone numbers also with their names?

Reply
Add Your Reply