Agent Skills: Android Persistence Standards

Implement Room database schemas and DataStore preferences with proper async patterns in Android. Use when defining Room entities, DAOs, migrations, or replacing SharedPreferences with DataStore. (triggers: **/*Dao.kt, **/*Database.kt, **/*Entity.kt, @Dao, @Entity, RoomDatabase)

UncategorizedID: hoangnguyen0403/agent-skills-standard/android-persistence

Install this agent skill to your local

pnpm dlx add-skill https://github.com/HoangNguyen0403/agent-skills-standard/tree/HEAD/skills/android/android-persistence

Skill Files

Browse the full folder contents for android-persistence.

Download Skill

Loading file tree…

skills/android/android-persistence/SKILL.md

Skill Metadata

Name
android-persistence
Description
Implement Room schemas and DataStore preferences with proper async patterns in Android. Use when the primary task is storage schema, DAO, migration, or preference isolation; defer auth-token/security storage, any CoroutineWorker/WorkManager task, Hilt graph wiring, and cache-policy design.

Android Persistence Standards

Priority: P0 (CRITICAL)

1. Configure Room Database

  • Return Flow<List<T>> for queries, use suspend for Write/Insert.
  • Keep @Entity data classes simple. Map to Domain models in Repository.
  • Use @Transaction for multi-table queries (Relations).

See DAO templates for Room DAO patterns.

2. Migrate to DataStore

  • Replace SharedPreferences with ProtoDataStore (type-safe) or PreferencesDataStore.
  • Inject singleton DataStore instance via Hilt.

See DAO templates for DataStore migration patterns.

Anti-Patterns

  • No IO on Main Thread: Room handles dispatchers, but verify Flow collected off-main.
  • No @Entity in UI Layer: Map to Domain or UI models in Repository.

References