android - Get Favorites Contacts list always null? -
i tried contacts same favorites contacts list on samsung galaxy s4. using code below:
public void getfavoritescontactslist(contentresolver cr) { uri queryuri = contactscontract.contacts.content_uri; string[] projection = new string[] { contactscontract.contacts._id, contactscontract.contacts.display_name, contactscontract.contacts.starred}; string selection =contactscontract.contacts.starred + "="+"1"; cursor cursor = managedquery(queryuri, projection, selection, null, null); while (cursor.movetonext()) { string contactid = cursor.getstring(cursor .getcolumnindex(contactscontract.contacts._id)); intent intent = new intent(intent.action_view); uri uri = uri.withappendedpath( contactscontract.contacts.content_uri, string.valueof(contactid)); intent.setdata(uri); string intenturistring = intent.touri(0); string title = (cursor.getstring( cursor.getcolumnindex(contactscontract.contacts.display_name))); name1.add(title); _idd.add(contactid); } cursor.close(); } but result null.
public map getfavoritecontacts(){ map contactmap = new hashmap(); uri queryuri = contactscontract.contacts.content_uri; string[] projection = new string[] { contactscontract.contacts._id, contactscontract.contacts.display_name, contactscontract.contacts.starred}; string selection =contactscontract.contacts.starred + "='1'"; cursor cursor = managedquery(queryuri, projection, selection, null, null); while (cursor.movetonext()) { string contactid = cursor.getstring(cursor .getcolumnindex(contactscontract.contacts._id)); intent intent = new intent(intent.action_view); uri uri = uri.withappendedpath( contactscontract.contacts.content_uri, string.valueof(contactid)); intent.setdata(uri); string intenturistring = intent.touri(0); string title = (cursor.getstring( cursor.getcolumnindex(contactscontract.contacts.display_name))); contactmap.put(title,intenturistring); } cursor.close(); return contactmap; }
Comments
Post a Comment