Sunday, May 19, 2013

[android help] Display correct values with CursorLoader/Adapter Android


I'm attempting to query Nickname and SIP Address from the contacts. The issue I'm running into is that both of them are stored in DATA1 column. So when I run a query, I only retrieve the Nicknames. What's a method of retrieving both of them and passing them into the SimpleCursorAdapter below? My sql query is potentially incorrect.



CursorLoader c = new CursorLoader(getActivity(), baseUri, CONTACTS_NUMBER_PROJECTION2, Data.MIMETYPE+" ='" + Nickname.CONTENT_ITEM_TYPE+"'", null, ORDER);

private static final String[] CONTACTS_NUMBER_PROJECTION2 = new String[] {
SipAddress.DISPLAY_NAME,
SipAddress.SIP_ADDRESS,
BaseColumns._ID};


Using a SimpleCursorAdapter, both Nickname.NAME and SipAddress.SIP_ADDRESS are nicknames.



SimpleCursorAdapter adapter = new SimpleCursorAdapter(getActivity(), R.layout.contact_list, null,
new String[] {Nickname.NAME, SipAddress.SIP_ADDRESS},
new int[] {R.id.text1, R.id.text2}, 0);


The screen shot looks like this. The smaller font should be the Sip Address.


If I change Nickname.CONTENT_ITEM_TYPE to SipAddress.CONTENT_ITEM_TYPE I get Sip Addresses instead of nicknames. I'm not sure how to get both to show up.


enter image description here



.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...