code: @SuppressWarnings({"unused", "WeakerAccess"})
      public void setOptOut(boolean userOptOut){
          final boolean enable = userOptOut;
          postAsyncSafely("setOptOut", new Runnable() {
              @Override
              public void run() {
                  // generate the data for a profile push to alert the server to the optOut state change
                  HashMap<String, Object> optOutMap = new HashMap<>();
                  optOutMap.put(Constants.CLEVERTAP_OPTOUT, enable);
  
                  // determine order of operations depending on enabled/disabled
                  if (enable) {  // if opting out first push profile event then set the flag
                      pushProfile(optOutMap);
                      setCurrentUserOptedOut(true);
                  } else {  // if opting back in first reset the flag to false then push the profile event
                      setCurrentUserOptedOut(false);
                      pushProfile(optOutMap);
                  }
                  // persist the new optOut state
                  String key = optOutKey();
                  if (key == null) {
                      getConfigLogger().verbose(getAccountId(), "Unable to persist user OptOut state, storage key is null");
                      return;
                  }
                  StorageHelper.putBoolean(context, storageKeyWithSuffix(key), enable);
                  getConfigLogger().verbose(getAccountId(), "Set current user OptOut state to: " + enable);
              }
          });
      }
docs: Use this method to opt the current user out of all event/profile tracking.
  You must call this method separately for each active user profile (e.g. when switching user profiles using onUserLogin).
  Once enabled, no events will be saved remotely or locally for the current user. To re-enable tracking call this method with enabled set to false.
  @param userOptOut boolean Whether tracking opt out should be enabled/disabled.