Thanks for the reply. I agree the API doc is very ambiguous. On Jul 30, 12:39 am, William Ferguson <[email protected]> wrote: > You appear to be using a combination of Android 1.5 and Android 2.0 > mechanisms. > Ie passing Android 2.0 constants to an Android 1.5 mechanism. > > Android 1.5 > > > Uri uri = Phone.CONTENT_URI; > > Phone.CONTACT_ID, > > Phone.DISPLAY_NAME, > > Phone.NUMBER, > > Phone.TYPE, Phone.LABEL, > > Android 2.0 > > > ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME, > > But I could be wrong. The ContactsContract provider is pretty unclear > IMHO. > I think you'll gain some mileage > from:http://stackoverflow.com/questions/1721279/how-to-read-contacts-on-an... > > On Jul 30, 7:47 am, j <[email protected]> wrote: > > > > > > > While iterating through my contacts database, the firstName > > (GIVEN_NAME) always returns an integer (0, 1, 2, ... 7) while the > > lastName (FAMILY_NAME) always returns null. I am running on HTC > > Incredible. What am I doing wrong? > > > Uri uri = Phone.CONTENT_URI; > > String[] projection = new String[] { > > Phone.CONTACT_ID, > > Phone.DISPLAY_NAME, > > Phone.NUMBER, > > Phone.TYPE, Phone.LABEL, > > ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME, > > ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME > > > }; > > > Cursor managedCursor = mContext.getContentResolver() > > .query(uri, projection, null, null, null); > > if(managedCursor == null) { > > Log.w(LOG_TAG, "managedCursor null"); > > return null; > > } > > > while(managedCursor.moveToNext()) { > > > long contactId = managedCursor.getLong( > > > managedCursor.getColumnIndex(Phone.CONTACT_ID)); > > String name = managedCursor.getString( > > > managedCursor.getColumnIndex(Phone.DISPLAY_NAME)); > > > String firstName = managedCursor.getString( > > > managedCursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME));// > > getFirstNameFromId(contactId); > > Log.d(LOG_TAG, "firstName: "+ firstName); > > String lastName = managedCursor.getString( > > > managedCursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME));// > > getLastNameFromId(contactId); > > Log.d(LOG_TAG, "lastName: "+ lastName); > > > }
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

