guillemroca/agent-skills-android/android-data-persistence
Claude Code and agent skill by guillemroca/agent-skills-android
- community
Checking that the SKILL.md file is still in the repository.
Use when implementing local data storage with Room, DataStore, or offline-first patterns. Covers entities, DAOs, migrations, Paging3, and the repository pattern for data management.
Install
npx vskill@latest install guillemroca/agent-skills-android/android-data-persistenceSKILL.md
The same SKILL.md was published earlier as guillemroca/agent-skills-android/android-data-persistence.
Android Data Persistence
Overview
Reliable data persistence is critical for Android apps. This skill covers Room (SQLite abstraction), DataStore (key-value and proto), offline-first architecture, Paging3 for large datasets, and the repository pattern that abstracts data sources from the rest of the app.
When to Use
- Setting up or modifying a Room database
- Writing database migrations
- Implementing offline-first data access
- Adding pagination for large datasets
- Choosing between Room, DataStore, and SharedPreferences
- Implementing the repository pattern
Skip when: Data is purely in-memory or comes only from a remote API with no caching.
Data Storage Decision Guide
| Requirement | Solution | |
|---|---|---|
| Structured data with relations | Room | |
| User preferences (key-value) | DataStore (Preferences) | |
| Typed settings with schema | DataStore (Proto) | |
| Large datasets with pagination | Room + Paging3 | |
| Simple flags or tokens | DataStore (Preferences) | |
| Never use | SharedPreferences (for new code) |
Core Process
Step 1: Room Setup
- Define entities:
- Define DAOs:
- Define the database:
Step 2: Migrations
- Always write migrations (never `fallbackToDestructiveMigration`):
- Test migrations:
Step 3: DataStore
- Preferences DataStore (key-value):
- Proto DataStore (typed schema):
Step 4: Repository Pattern
- Single source of truth (offline-first):
Step 5: Paging3
- Paginate large datasets:
Step 6: Data Mappers
- Separate data models per layer:
Common Rationalizations
| Shortcut | Why It Fails | |
|---|---|---|
| "fallbackToDestructiveMigration is fine for now" | Users lose their data. Write proper migrations from day one. | |
| "SharedPreferences works fine" | SharedPreferences isn't type-safe, isn't coroutine-friendly, and has known bugs with apply(). | |
| "We don't need offline support" | Users on subways, elevators, and airplanes disagree. Cache early. | |
| "One model for all layers is simpler" | Coupling DB schema to UI makes both harder to change. | |
| "Paging is overkill" | Loading 10,000 items into memory causes OOM. Paginate datasets over ~100 items. |
Red Flags
fallbackToDestructiveMigration()in production code- SharedPreferences in new code
- No migration tests
- Room entities used directly in UI layer
suspendfunctions whereFlowshould be used (for observable data)- No error handling in repository sync operations
- Loading entire dataset into memory without pagination
Verification
- [ ] Room entities, DAOs, and database defined correctly
- [ ]
exportSchema = trueset on@Database - [ ] Migrations written and tested for every schema change
- [ ] DataStore used for preferences (not SharedPreferences)
- [ ] Repository pattern abstracts data sources
- [ ] Offline-first: local DB is single source of truth
- [ ] Paging3 used for large datasets
- [ ] Separate data models per layer (Entity, Domain, Network)
- [ ]
./gradlew testand./gradlew connectedAndroidTestpass
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/android-data-persistence/SKILL.md
Popularity
- Repository stars
- 2
- 7-day trend score
- 5
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/guillemroca/agent-skills-android/android-data-persistence)