private KeysetHandle getOrGenerateNewKeysetHandle() throws IOException, GeneralSecurityException {
    return new AndroidKeysetManager.Builder()
        .withSharedPref(getApplicationContext(), TINK_KEYSET_NAME, PREF_FILE_NAME)
        .withKeyTemplate(AeadKeyTemplates.AES256_GCM)
        .withMasterKeyUri(MASTER_KEY_URI)
        .build()
        .getKeysetHandle();
  }
A custom application that initializes the Tink runtime at application startup.
java_src/examples/android/helloworld/app/src/main/java/com/helloworld/TinkApplication.java