public static boolean saveSecret(
      Context context, AccountIndex index, String secret, OtpType type, Integer counter) {
    if (secret != null) {
      AccountDb accountDb = DependencyInjector.getAccountDb();
      accountDb.add(index.getName(), secret, type, counter, null, index.getIssuer());
      // TODO: Consider having a display message that activities can call and it will present a
      // toast with a uniform duration, and perhaps update status messages (presuming we have a way
      // to remove them after they are stale).
      Toast.makeText(context, R.string.secret_saved, Toast.LENGTH_LONG).show();
      ((Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE)).vibrate(VIBRATE_DURATION);
      return true;
    } else {
      Log.e(LOCAL_TAG, "Trying to save an empty secret key");
      Toast.makeText(context, R.string.error_empty_secret, Toast.LENGTH_LONG).show();
      return false;
    }
  }
Saves the secret key to local storage on the phone.

@param index the intended {@link AccountIndex} to update/add
@param secret the secret key
@param type hotp vs totp
@param counter only important for the hotp type
@return {@code true} if the secret was saved, {@code false} otherwise.
java/com/google/android/apps/authenticator/AuthenticatorActivity.java