Tuesday, 15 May 2012

android - get name of last inserted contact -



android - get name of last inserted contact -

i calling , intent add together contact startactivityforresult this:

intent intent = new intent(intent.action_insert_or_edit); intent.settype(contactscontract.contacts.content_item_type); intent.putextra(contactscontract.intents.insert.name, u.getname()); startactivityforresult(intent, 0);

the problem result_code never result_ok (so data in onactivityresult null). think because when add together contact need press button activity.

what need name of lastly inserted contact. tried:

string name = null; cursor cur = appdata.getcontentresolver().query( contactscontract.contacts.content_uri, null, null, null, null); if (cur.getcount() > 0) { cur.movetofirst(); // or movetolast name = cur.getstring(cur .getcolumnindex(contactscontract.contacts.display_name)); }

android android-contacts

No comments:

Post a Comment