views:

38

answers:

0

It may be wrong place to log my query, but its urgent. can anyone please help me how to delete google accounts from "accounts and sync". I'm trying to call this line my app: AccountManagerService.getSingleton().onServiceChanged(null,true);

whereas onServiceChanged() method is defined in AccountManagerService.java.

=============================================================================

public void onServiceChanged(AuthenticatorDescription desc, boolean removed) {
    boolean accountDeleted = false;
    SQLiteDatabase db = mOpenHelper.getWritableDatabase();
    Cursor cursor = db.query(TABLE_ACCOUNTS,
            new String[]{ACCOUNTS_ID, ACCOUNTS_TYPE, ACCOUNTS_NAME},
            ACCOUNTS_TYPE + "=?", new String[]{desc.type}, null, null, null);
    try {
        while (cursor.moveToNext()) {
            final long accountId = cursor.getLong(0);
            final String accountType = cursor.getString(1);
            final String accountName = cursor.getString(2);
            Log.d(TAG, "deleting account " + accountName + " because type "
                    + accountType + " no longer has a registered authenticator");
            db.delete(TABLE_ACCOUNTS, ACCOUNTS_ID + "=" + accountId, null);
            accountDeleted = true;
        }
    } finally {
        cursor.close();
        if (accountDeleted) {
            sendAccountsChangedBroadcast();
        }
    }

=============================================================================

this piece of code is not doing anything i feel exception is bieng thrown which is handled at lower layer.