[Solved] How to get contact id after add a new contact in android?


Try this code,

ContentProviderResult[] res = getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);

Uri myContactUri = res[0].uri;
int lastSlash = myContactUri.toString().lastIndexOf("https://stackoverflow.com/");
int length = myContactUri.toString().length();
int contactID = Integer.parseInt((String) myContactUri.toString().subSequence(lastSlash+1, length));

I hope this code help you..

0

solved How to get contact id after add a new contact in android?