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.0.2-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 is write-scoped.
  • prefs.remove_key is delete-scoped and requires withAllToolAccess().

Tool Matrix

NameIdScopeDescriptionSecurity
List Preference Keysprefs.list_keysReadLists keys from a SharedPreferences store.Moderate
Get Preference Valueprefs.get_valueReadReads one preference value.High
Set Preference Valueprefs.set_valueWriteWrites one preference value.High
Remove Preference Keyprefs.remove_keyDeleteDeletes one preference key.High

Tool Details

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