DataStores
Inspect and edit Jetpack DataStore (Preferences) values from Snapbug Desktop. This plugin extends the Preferences inspector, so registered DataStores appear alongside SharedPreferences entries.
Features
- View all DataStore keys and values
- Edit values directly from the Desktop app
- Real-time updates as values change in the app
- Side-by-side display with SharedPreferences
Setup
Add the DataStores dependency to your module's build.gradle.kts:
dependencies {
debugImplementation("ai.snapbug:snapbug-datastores:1.0.0")
releaseImplementation("ai.snapbug:snapbug-datastores-no-op:1.0.0")
}Or with version catalog:
[libraries]
snapbug-datastores = { module = "ai.snapbug:snapbug-datastores", version.ref = "snapbug" }
snapbug-datastores-no-op = { module = "ai.snapbug:snapbug-datastores-no-op", version.ref = "snapbug" }Always use the -no-op variant for release builds to ensure zero overhead in production.
Register a DataStore
After creating your Preferences DataStore, register it with Snapbug so it appears in the Desktop inspector.
val Context.dataStore by preferencesDataStore(name = "settings")
// In your Application.onCreate() or initialization code, after Snapbug.initialize():
snapbugRegisterPreference(
SnapbugDatastorePreference(
name = "App Settings",
dataStore = context.dataStore
)
)You can register multiple DataStores:
val Context.settingsStore by preferencesDataStore(name = "settings")
val Context.userStore by preferencesDataStore(name = "user_prefs")
snapbugRegisterPreference(
SnapbugDatastorePreference(name = "Settings", context.settingsStore)
)
snapbugRegisterPreference(
SnapbugDatastorePreference(name = "User Preferences", context.userStore)
)Registered DataStores appear in the Preferences section of Snapbug Desktop alongside any SharedPreferences entries. The name parameter is the display label shown in the Desktop app.
Editing Values
From Snapbug Desktop:
- Select SharedPreferences from the left sidebar.
- Registered DataStores appear as separate sections.
- Click on any value to edit it.
- Changes are applied immediately to the DataStore on the device.
This is useful for testing edge cases -- quickly change feature flags, user settings, or cached values without rebuilding the app.