Android ContactsContract.Contact missing constants from the API?
I've been using the ContactsContract api for some time now and I've come across two "columns" listed in the API page for ContactsContract.Contacts that do not appear to actually be assessable.
The values are (under the columns heading): "NAME_RAW_CONTACT_ID" and "DISPLAY_NAME_PRIMARY"
By my reading of the API these two values would seem to connect to the Structured Name (in DATA) used to construct the display name for the given contact. Having access to this directly from the contact table would be incredibly useful to me at the moment, but as far as I can tell they are not actually in the working api (I've tested against both 2.1 and 2.2).
The associated constants do not exist in the Contacts object, and attempting to access the fields directly (by using the lower case string versions I've seen in code dumps online) turns up with an sql error -- invalid column, as you might expect.
Has anyone had any better luck wit开发者_开发百科h accessing these? Are these actually in the API?
Edit: I did some more checking and here's some related values from RawContacts that are listed on the API but appear to not actually be in it: DISPLAY_NAME_ALTERNATIVE, DISPLAY_NAME_PRIMARY, DISPLAY_NAME_SOURCE, PHONETIC_NAME, PHONETIC_NAME_STYLE, SORT_KEY_ALTERNATIVE, and SORT_KEY_PRIMARY.
All of these appear to be features not yet in the API that are mistakenly not filtered out when the javadoc was released. If other folks are unable to access these features as well it might be worth filing a bug report over.
Interesting thing about these items you mention. Where it says "since API level" no level is mentioned. I think a bug report is in order.
I too found the same thing . When i went through the native contacts application they have been using the DISPLAY_NAME_ALTERNATIVE .In the API they have listed these in an interface
http://developer.android.com/reference/android/provider/ContactsContract.DataColumnsWithJoins.html
I also pulled the native contacts and checked the raw_contacts table. There I was able to find the "display_name_alt" as a coulmn.
So i dont know how to go about things . I dont know if the name of the column would help
I also wanted to use some of these fields (ver 2.2), but the ContactsContract.DataColumnsWithJoins.DISPLAY_NAME_ALTERNATIVE static string is not visible. So I used directly its value for the query, "display_name_alt", and I had that field's data.
I used also a query asking for all fields (putting null in 'String[] projection' variable of managedQuery() function) and retrieved all fileds. I inserted a mistake in sortOrder variable, to retrieve the error and the automatically created SQL. So SQL was like this
near "mimetype": syntax error: , while compiling:
SELECT
data_version,
phonetic_name,
phonetic_name_style,
contact_id,
lookup,
data12,
data11,
data10,
mimetype,
data15,
data14,
data13,
display_name_source,
data_sync1,
data_sync3,
data_sync2,
data_sync4,
account_type,
custom_ringtone,
status_update_id,
status_updates.status AS status,
data1,
data4,
data5,
data2,
data3,
data8,
account_type AS ext_account_Type,
data9,
group_sourceid,
data6,
account_name,
data7,
display_name,
in_visible_group,
display_name_alt,
contacts_status_updates.status_res_package AS contact_status_res_package,
is_primary,
contacts_status_updates.status_ts AS contact_status_ts,
raw_contact_id,
times_contacted,
contacts_status_updates.status AS contact_status,
status_updates.status_res_package AS status_res_package,
status_updates.status_icon AS status_icon,
contacts_status_updates.status_icon AS contact_status_icon,
presence.mode AS mode,
version,
last_time_contacted,
res_package, _id,
name_verified,
status_updates.status_ts AS status_ts,
dirty,
is_super_primary,
photo_id,
send_to_voicemail,
name_raw_contact_id,
contacts_status_updates.status_label AS contact_status_label,
status_updates.status_label AS status_label,
sort_key_alt,
starred,
sort_key,
agg_presence.mode AS contact_presence,
sourceid
FROM
view_data_restricted data
LEFT OUTER JOIN agg_presence ON (agg_presence.presence_contact_id=contact_id)
LEFT OUTER JOIN status_updates contacts_status_updates ON (status_update_id=contacts_status_updates.status_update_data_id)
LEFT OUTER JOIN presence ON (presence_data_id=data._id)
LEFT OUTER JOIN status_updates ON (status_updates.status_update_data_id=data._id)
WHERE (1)
ORDER BY contact_id mimetype
So you can see all available fields.
That I don't know how, is to get a Cursor with an SQL string from a Uri, like rawQuery() ...
精彩评论