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.

Answers


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:

uri.buildUpon()
   .appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER,
         "true").build()

For further explanation read official docs about content providers.


Need Your Help

Transfering ASP Classic Pages from Windows to Linux

windows linux asp-classic move

Has anyone tried a solution to host ASP classic pages on something else than IIS/Windows? I'm wondering if it would be a good idea to try one of the solutions for that problem. I know about Sun Java

How to reserve a DIV width with “left:100%” CSS rule

html css css-position absolute

If placing an absolute position with left:100%, the DIV will not reserve the normal width depending on its content. Instead, the width will be minimized by breaking the text over spaces.

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.