【问题标题】:Android: how to delete account from database which are displayed under "accounts and sync" from my own applicationAndroid:如何从我自己的应用程序的“帐户和同步”下显示的数据库中删除帐户
【发布时间】:2010-07-23 13:52:54
【问题描述】:

如何从“帐户和同步”中删除 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();
        }
    }

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

【问题讨论】:

    标签: android sdk account


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-26
      • 1970-01-01
      • 2013-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-17
      相关资源
      最近更新 更多