If you want to access the phone contacts, you can use the following code:
private void getMyPhoneNumber(){
try{
String[] projection = new String[] {
People._ID,
People.LABEL,
People.NAME,
People.NUMBER,
People.PRIMARY_EMAIL_ID
};
Uri contacts = People.CONTENT_URI;
Cursor managedCursor = managedQuery(contacts,
projection,
null,
null,
People.NAME + " ASC");
alertbox("Contacts", getColumnData(managedCursor));
}
catch(Exception e){
alertbox("Exception", e.getMessage());
}
}
private String getColumnData(Cursor cur){
String ContactsName="";
if (cur.moveToFirst()) {
String name;
String phoneNumber;
String email;
String Label;
int nameColumn = cur.getColumnIndex(People.NAME);
int phoneColumn = cur.getColumnIndex(People.NUMBER);
String imagePath;
do {
name = cur.getString(nameColumn);
phoneNumber = cur.getString(phoneColumn);
email =cur.getString(cur.getColumnIndex(People.PRIMARY_EMAIL_ID));
Label =cur.getString(cur.getColumnIndex(People.LABEL));
ContactsName+="name:"+name+" Phoneno:"+phoneNumber+"email:"+email+"label:"+Label;
} while (cur.moveToNext());
}
return ContactsName;
}
My Self Atul Yadav and have exp. in Application Developer in a wide variety of business applications. Particularly interested in client/server and relational database design using MS-SQL Server.
Specialties:
Microsoft Certified Professional
Asp.net,asp classic,C#, xml ,javascript,Flex action script,
SQL,Smart phone Applications.
My Blogs:
Flex Blog: Flex.co.nr
Android Blog: Android Beginners
Dot Net Blog: Dot Net Debugger