i'm new to android and probably this is silly question but please help. i am receiving output as
contact Name: RRRR
phone Number: XXXXXXXXX
contact Name: SSSS
phone Number: YYYYYYYYY
phone Number: aaaaaaaaa
phone Number: zzzzzzzzz
contact Name: TTTT
phone Number: XXXXXXXXX
phone Number: ccccccccc
.
.
.
//code
public void readContacts() {
StringBuffer sb = new StringBuffer();
sb.append("......Contact Details.....");
ContentResolver cr = getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
String phone = null;
String name = null;
if (cur.getCount() > 0) {
while (cur.moveToNext()) {
String id = cur.getString(cur .getColumnIndex(ContactsContract.Contacts._ID));
name = cur .getString(cur .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
if (Integer .parseInt(cur.getString(cur .getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
System.out.println("name : " + name + ", ID : " + id); sb.append("\n Contact Name:" + name);
Cursor pCur = cr.query( ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", new String[] { id }, null);
while (pCur.moveToNext()) {
phone = pCur .getString(pCur .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
sb.append("\n Phone number:" + phone+":"+pCur.getCount()); System.out.println("phone" + phone);
}pCur.close();
}
outputText.setText(sb);
}
}
}
P.S: how can i store the ouput in container and then bundle it and send to server ?
thanks in advance,