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_valueis write-scoped.prefs.remove_keyis delete-scoped and requireswithAllToolAccess().
Tool Matrix
| Name | Id | Scope | Description | Security |
|---|---|---|---|---|
List Preference Keys | prefs.list_keys | Read | Lists keys from a SharedPreferences store. | Moderate |
Get Preference Value | prefs.get_value | Read | Reads one preference value. | High |
Set Preference Value | prefs.set_value | Write | Writes one preference value. | High |
Remove Preference Key | prefs.remove_key | Delete | Deletes 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.