views:

35

answers:

1

when i deal with deleting a contact using new google api,i got the problem

here is my problem

Following is the only response :

You have to run a sync process, so it updates with Google Contacts, than it will be removed permanently. Check for deleted flag

so what should i do to run a sync process which updates with Google Contacts?

A: 

This method could resolve your probromm. but you must have set your account.

private void requestSync()
{
    AccountManager am = AccountManager.get(this);
    Account[] accounts = am.getAccounts();

    for (Account account : accounts)
    {
        int isSyncable = ContentResolver.getIsSyncable(account, ContactsContract.AUTHORITY);

        if (isSyncable > 0)
        {
            Bundle extras = new Bundle();
            extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
            ContentResolver.requestSync(accounts[0], ContactsContract.AUTHORITY, extras);
        }
    }
}