Hi all, This is my first post to this group (any group), but I wanted to share my experience with the new Contacts API so far. I had a little application which accessed a contact's notes via Contacts.People.CONTENT_URI, accessing the NOTES field with cursor.getString(cursor.getColumnIndex(People.Notes)). Simple enough.
Then, along comes the new API with it's ContactsContract and ContactsContract.CommonDataKinds.xxx. Oh my gosh! It took me forever to figure out how to find the contents of a note. Maybe I'm just dense! :) As it turns out, a note (along with many other data items) is stored in the 'data' directory of the contact available through ContactsContract.Data.CONTENT_URI. The note's mime-type is specified as ContactsContract.CommonDataKinds.Note.CONTENT_ITEM_TYPE, and the column containing the note is ContactsContract.CommonDataKinds.Note.NOTE. So, here's how I constructed my new getNote(long contactId) method: private String getNote(long contactId) { Log.d(LOGGING_TAG, "getNote for contactId: " + contactId); String rv = null; String[] projection = new String[] { ContactsContract.CommonDataKinds.Note.NOTE }; String whereClause = ContactsContract.Data.RAW_CONTACT_ID + " = ? AND " + ContactsContract.Data.MIMETYPE + " = ?"; String[] whereParams = new String[]{Long.toString(contactId), ContactsContract.CommonDataKinds.Note.CONTENT_ITEM_TYPE}; Cursor c = getContentResolver().query (ContactsContract.Data.CONTENT_URI, projection, whereClause, whereParams, null); if (c.moveToFirst()) { rv = c.getString(0); } c.close(); Log.d(LOGGING_TAG, "getNote returning " + rv); return rv; } There are other, easier means for accessing some of the other 'data' items (for example, ContactsContract.CommonDataKinds.Phone has it's own CONTENT_URI), but this was the only way I could find to access a note. I hope it's helpful to someone else. Peace, Jef -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en