Hello,

I'm writing an app on to make use of the owner's data (first, 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.

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 insights.
Thanks!

-- 
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

Reply via email to