How to delete the contacts on android 2.2?
I need to delete the duplicate contacts and then inserting the new contact on Android 2.2.
How to do this?
give me any sample code or sites for this.
May be this will help you,
To delete the content item from android you need a content URI and some deletion criteria.
Every content type has its own content URI. If you're writing your contacts sync adapter, then you might want to use ContactsContract.RawContacts.CONTENT_URI.
Other thing you need is a ContentResolver - an interface to communicate with a content provider (an operations, such as insert, update and delete are defined in this interface). You can get ContentResolver by calling getContentResolver from your application context.
So, here is the snippet of code that should delete ALL the contacts (not tested it though):
ContentCesolver cr = getContentResolver(); URI uri = RawContacts.CONTENT_URI; cr.delete(uri, null, null);
Note that when you're using RawContacts.CONTENT_URI, the contact item is not deleted. Instead it is only marked for deletion. To delete it completely you should add a ContactsContract.CALLER_IS_SYNCADAPTER parameter to your URI:
uri.buildUpon() .appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true").build()
For further explanation read official docs about content providers.