当前位置: 代码迷 >> Android >> Android:如何从数据库中删除我自己的应用程序中“帐户和同步”下显示的帐户
  详细解决方案

Android:如何从数据库中删除我自己的应用程序中“帐户和同步”下显示的帐户

热度:9   发布时间:2023-08-04 09:51:13.0

如何从“帐户和同步”中删除Google帐户? 我正在尝试将此行称为我的应用程序:

AccountManagerService.getSingleton().onServiceChanged(null,true);

而onServiceChanged()方法是在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();
        }
    }

这段代码没有做任何事情。 我觉得这是在较低层处理的异常。

试试 。

  相关解决方案