Friday, September 3, 2010

[android-developers] Getting Owner and Contact Data

Hello,

I'm writing an app on my IO Magic to make use of the owner's data
(first, middle, last, email(s), phone(s)) and one or more contacts the
owner
can choose. The application will find common patterns and whatnot.

I have given my app READ_CONTACTS, WRITE_CONTACTS, READ_OWNER_DATA,
WRITE_OWNER_DATA permissions in my AndroidManifest.xml

Initially I used the People class which was deprecated, then I
switched to ContactsContract.Contacts... to try pull explicitly the
first (given), middle, and last (family)
names, then phone numbers, emails, etc... but I cannot seem to be able
to fetch these columns via:

Cursor c1 =
getContentResolver().query(ContactsContract.Data.CONTENT_URI, null,
ContactsContract.CommonDataKinds.StructuredName.CONTACT_ID +" = ?",
new String[]{id}, null);

Or even this

Cursor cc =
getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,
null, null,null, null);
if (cc.moveToFirst()){
String [] names = cc.getColumnNames();
for (int j=0; j<names.length; j++){
Log.d("Contacts", "COL NAME:
"+names[j]);
Log.d("Contacts", "========>COL VALUE:
"+cc.getString(cc.getColumnIndexOrThrow(names[j]))+"\n\n");
}

}

to show all column names but I'm not getting any relevant information.
I can get the phone number (data 0 or data 1), but not first, middle,
and last. I need to access as much of the user's data for the
algorithm to work as it compares it with other people to find trends
and patterns. The more complete the data the better.

Here's another alternative way I tried with the first cursor c1:

String lookup =
c1.getString(c.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
Cursor cc =
getContentResolver().query( Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI,
lookup), null, null, null, null);

and still I cannot get the owner's or a contact's data that I want.

I don't understand why the CommonDataKinds object is in the API when
we can't even use these to fetch any contact's data:
ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME
ContactsContract.CommonDataKinds.StructuredName.MIDDLE_NAME
ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME


Does anyone have any clue as to why I can't get the contact fields I
need... or how I can get them?
I really appreciate any insight.

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate