getInstance

fun getInstance(context: Context, fileName: String = "secret_shared_prefs" + context.packageName, aliasName: String = fileName): SharedPreferences

Creates or retrieves an EncryptedSharedPreferences instance configured to access Legacy SDK encrypted SharedPreferences.

This method recreates the exact encryption configuration used by the Legacy SDK, allowing the migration process to decrypt and read legacy data.

Return

A SharedPreferences instance that can read/write encrypted data.

Parameters

context

The Android context used to access SharedPreferences and KeyStore.

fileName

The name of the SharedPreferences file. Defaults to "secret_shared_prefs" + the application package name.

aliasName

The alias name for the master key in the AndroidKeyStore. Defaults to the same value as fileName. Common values from the Legacy SDK: - "ORG_FORGEROCK_V_1_DEVICE_REPO" for device repository data - Custom identifiers for application-specific storage

Throws

if the AndroidKeyStore is unavailable

if the SharedPreferences file cannot be accessed