Akshay Kumar
Jun 19, 2017
3:27 pm

Remove Google account programmatically


Is it possible with the Knox Standard SDK or Knox Customization SDK to remove a Google Account programmatically on a device?



Similar topics

No similar topics found.
Samuel V.Samsung SEAP Moderator
Jun 27, 2017
10:57 pm

Hi Akshay,

Unfortunately, we don't directly support the use case of removing a specific Google account.

But we do have APIs that:

1) Prevent the addition of a type/specific account:

private void preventAdditionOfGoogleAccount() {
    EnterpriseDeviceManager edm = (EnterpriseDeviceManager) getSystemService(EnterpriseDeviceManager.ENTERPRISE_POLICY_SERVICE);
    try {
        List<String> blackList = new ArrayList<String>();
        // Supported account types can be retrieved from getSupoprtedAccountTypes()
        // For example supported Google account type will be "com.google"
        boolean success = edm.getDeviceAccountPolicy().addAccountsToAdditionBlackList("com.google", blackList);
        if (success) {
            Log.d(TAG, "Addition to blacklist is a success");
        } else {
            Log.d(TAG, "Addition to blacklist is a failure");
    } catch (SecurityException e) {
        Log.w(TAG, "SecurityException: " + e);

2) Remove all accounts of a certain type (ex. @google.com accounts):

 EnterpriseDeviceManager edm = (EnterpriseDeviceManager) getSystemService(EnterpriseDeviceManager.ENTERPRISE_POLICY_SERVICE);
  SecurityPolicy securityPolicy = edm.getSecurityPolicy();
  try {
      boolean result = securityPolicy.removeAccountsByType(
      if(true == result)
          //account deleted successfully
  }catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);

Best regards,