android - CursorLoader/adapter not displaying correct values -


i'm attempting query nickname , sip address contacts. issue i'm running both of them stored in data1 column. when run query, retrieve nicknames. what's method of retrieving both of them , passing them simplecursoradapter below?

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 simplecursoradapter, both nickname.name , sipaddress.sip_address 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 this. smaller font should sip address.

if change nickname.content_item_type sipaddress.content_item_type sip addresses instead of nicknames. i'm not sure how both show up.

enter image description here

update:

i changed nickname.name , sipaddress.sip_address nickname.data7 , nickname.data*, respectively. added 'null' selectionargs. both nickname , sip address show not on same row:

enter image description here

update 2:

i stored sip , nick name value under structuredname.display_name , structuredname.given_name, loaded them adapter. change selectionargs data.mimetype+" ='" + structuredname.content_item_type+"'"

this result: enter image description here

 if (key.equals("alias")) {                             contacts.add(contentprovideroperation                                     .newinsert(                                             contactscontract.data.content_uri)                                     .withvaluebackreference(                                             contactscontract.data.raw_contact_id,                                             0)                                     .withvalue(                                             contactscontract.data.mimetype,                                             contactscontract.commondatakinds.structuredname.content_item_type)                                     .withvalue(                                             contactscontract.commondatakinds.structuredname.display_name,                                             userdict.get(key).tostring())                                     .build());                         } if (key.equals("sipext")) {                             contacts.add(contentprovideroperation                                     .newinsert(                                             contactscontract.data.content_uri)                                     .withvaluebackreference(                                             contactscontract.data.raw_contact_id,                                             0)                                     .withvalue(                                             contactscontract.data.mimetype,                                             contactscontract.commondatakinds.structuredname.content_item_type)                                     .withvalue(                                             contactscontract.commondatakinds.structuredname.given_name,                                             userdict.get(key).tostring())                                     .build());                         } 

as documentation says, contact details different mimetypes stored in different records in 1 contacts data table, , have one-to-one relation contactid. because of practically impossible (i think) sip number , nickname in 1 cursor row.

here database scheme fragment courtesy of breatheinmyvoid / habrahabr.ru

for inserting 2 structuredname values shoud use single insert:

    contacts.add(contentprovideroperation                                 .newinsert(                                         contactscontract.data.content_uri)                                 .withvaluebackreference(                                         contactscontract.data.raw_contact_id,                                         0)                                 .withvalue(                                         contactscontract.data.mimetype, contactscontract.commondatakinds.structuredname.content_item_type)                                 .withvalue(                                         contactscontract.commondatakinds.structuredname.display_name,                                         currentnickname)                                 .withvalue(                                         contactscontract.commondatakinds.structuredname.given_name,                                         currentsipno)                                 .build()); 

to show data 2 different mimetypes in form of list, two-column gridview may used, if correct ordering (first contactid, mimetype) set.

if full row customization wanted, can create arraylist of simple objects containing sip-nick pair, fill using data 2 cusors (nick , sip) ordered contactid , use array adapter show them in listview.

alternatively, can load two cursors in custom adapter: nicknames , sipnumbers. extend, example, simplecursoradapter, passing cursor constructor along base cursor. in newview / bindview can perform lookup in additional cursor , corresponding data.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -