Android. Can't remove contact from phone fully
<p>I add contact to phone using this code:</p>

<p>(
Previously were added permissions to Android Manifest:

 )</p>

<pre><code>        String name = contact.name;
        String url = contact.url;
        ArrayList&lt;ContentProviderOperation&gt; ops = new ArrayList&lt;ContentProviderOperation&gt;();
        ops.add(ContentProviderOperation
                .newInsert(ContactsContract.RawContacts.CONTENT_URI)
                .withValue(ContactsContract.RawContacts.ACCOUNT_TYPE,
                        acountType)
                .withValue(ContactsContract.RawContacts.ACCOUNT_NAME,
                        acountName).build());
        ops.add(ContentProviderOperation
                .newInsert(ContactsContract.Data.CONTENT_URI)
                .withValueBackReference(
                        ContactsContract.Data.RAW_CONTACT_ID, 0)
                .withValue(
                        ContactsContract.Data.MIMETYPE,
                        ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE)
                .withValue(
                        ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME,
                        name).build());
        ops.add(ContentProviderOperation
                .newInsert(ContactsContract.Data.CONTENT_URI)
                .withValueBackReference(
                        ContactsContract.Data.RAW_CONTACT_ID, 0)
                .withValue(
                        ContactsContract.Data.MIMETYPE,
                        ContactsContract.CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE)
                .withValue(
                        ContactsContract.CommonDataKinds.SipAddress.SIP_ADDRESS,
                        url).build());

        // Ask the Contact provider to create a new contact
        try {
            getContentResolver()
                    .applyBatch(ContactsContract.AUTHORITY, ops);
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (OperationApplicationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
</code></pre>

<p>Then I tried to remove contact from phone, but this procedure can't remove contact from RawContacts and Data.</p>

<pre><code>            String deleteContact = contact_info.getContact();

            ContentResolver cr = getContentResolver();
            Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,
                    null, null, null, null);

            while (cur.moveToNext()) {
                try{
                    String lookupKey = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
                    Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey);
                    System.out.println("The uri is " + uri.toString());
                    String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
                    if(deleteContact.equalsIgnoreCase(name)){
                        cr.delete(uri, null, null);
                    }
                }
                catch(Exception e)
                {
                    System.out.println(e.getStackTrace());
                }
            }
</code></pre>

<p>Could you please help me, what is the root cause of this problem?</p>
