I have the following Cursor that gets the phone number and the calendar
Spinner imgpayment = (Spinner) findViewById(R.id.imgpayment);
Cursor mCursor = getContentResolver().query(
ContactsContract.Data.CONTENT_URI,
new String[]{ContactsContract.Data._ID, ContactsContract.Data.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER,
ContactsContract.CommonDataKinds.Phone.TYPE},
ContactsContract.Data.MIMETYPE + "='" +
ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE + "' AND " +
ContactsContract.CommonDataKinds.Phone.NUMBER + " IS NOT NULL", null,
ContactsContract.Data.DISPLAY_NAME + " ASC");
startManagingCursor(mCursor);
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_2,
mCursor, // cursor
new String[]{ContactsContract.Data.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER}, // cursor
new int[]{android.R.id.text1, android.R.id.text2}
);
imgpayment.setAdapter(adapter);
mCursor.moveToFirst();
while (!mCursor.isAfterLast()) {
contactos.add(mCursor.getString(mCursor.getColumnIndex("DISPLAY_NAME"))); //add the item
mCursor.moveToNext();
}
while (!mCursor.isAfterLast()) {
contactosCel.add(mCursor.getString(mCursor.getColumnIndex("NUMBER"))); //add the item
mCursor.moveToNext();
}
This cursor gets the 2 data well, but at the time of obtaining the number and the name separately to 2 separate ArrayList, I get the name correctly but the phone is impossible for me to help?
When trying to do
(mCursor.getString(mCursor.getColumnIndex("NUMBER")))
but with "display_name" if I get it:
and the cursor if it takes the 2 data, because when the cursor is displayed on an adaptercursor the name appears with the phone