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;
}