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,

How to remove a contact programmatically in android

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:


For further explanation read official docs about content providers.

Need Your Help

Is this normal behavior for mysql_real_escape_string?

php mysql

I just disabled magic_quotes_gpc and I notice that the user input into my database has apostrophes as if nothing was escaped.

Iframes and memory management in Javascript

javascript jquery memory-management iframe

I have links that load pages into iframes. I have been monitoring the accumulation of data in memory using Google Chrome's memory heap profiler and I noticed some leaks in memory.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.