Preferences

Register the native Android preferences tool suite to read and mutate SharedPreferences values under explicit store and key restrictions.

Install

Published artifact: ai.ansight:ansight-tools-preferences-android.

dependencies {
    debugImplementation("ai.ansight:ansight-tools-preferences-android:1.4.0-preview.1")
}

Register the Suite

import ai.ansight.runtime.AnsightOptions
import ai.ansight.tools.preferences.withPreferencesTools

val options = AnsightOptions.createBuilder()
    .withPreferencesTools {
        withDefaultStore("${application.packageName}_preferences")
        allowKeyPrefix("debug.")
    }
    .withReadWriteToolAccess()
    .build()

Registration API

  • withPreferencesTools(...): registers the suite.
  • withDefaultStore(...): sets the default SharedPreferences store.
  • allowStore(...): allows a store.
  • allowKey(...) / allowKeyPrefix(...): allow specific keys or prefixes.

Specific Concerns

  • Preference values often include configuration or user state.
  • Restrict stores, keys, or key prefixes at registration time.
  • prefs.set_value uses Write.
  • prefs.remove_key uses Critical and requires withAllToolAccess().

Tool Matrix

NameIdPolicyDescription
List Preference Keysprefs.list_keysReadLists keys from a SharedPreferences store.
Get Preference Valueprefs.get_valueReadReads one preference value.
Set Preference Valueprefs.set_valueWriteWrites one preference value.
Remove Preference Keyprefs.remove_keyCriticalDeletes one preference key.

Tool Details

Use read tools for inspection. Enable write and critical tools only when a local debugging workflow needs preference repair.