android-data-layer

Implements Android data layers with Repository pattern, Room, and offline-first synchronization.

Updated Jul 1, 2026
One-click install
npx skills add https://github.com/w0lzard/Wolzard-s-Marketplace --skill android-data-layer-w0lzard
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: android-data-layer
Source: https://github.com/w0lzard/Wolzard-s-Marketplace/tree/main/plugins/personal-skills/skills/android-data-layer
Command: npx skills add https://github.com/w0lzard/Wolzard-s-Marketplace --skill android-data-layer-w0lzard

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building an Android data layer requires coordinating repositories, Room databases, network sources, and sync strategies without leaking implementation details upward. This Skill provides proven patterns and code templates so the data layer stays decoupled, offline-capable, and correctly layered. ## Core Features & Use Cases - Repository Pattern: Implements repositories as the single source of truth with Flow-based streams, Result-returning refresh operations, and domain error mapping at the boundary. - Room Local Database: Covers entities, DAOs with Flow vs suspend return types, database setup with Hilt, and full Kotlin Multiplatform configuration including BundledSQLiteDriver and per-target KSP wiring. - Offline-First Strategies: Provides stale-while-revalidate reads and outbox-pattern writes backed by WorkManager for reliable sync. - Use Case: When adding a news feed feature to an Android app, use this Skill to scaffold the repository, Room DAO and entities, DTO-to-domain mapping, and a WorkManager sync worker that survives process death. ## Quick Start Implement the data layer for my Android app with a Room-backed repository, offline-first refresh, and proper error mapping.

Frequently Asked Questions about android-data-layer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement the Repository pattern in Android with Room?

Create a repository that exposes a Flow from the Room DAO as the single source of truth and a suspend refresh function that fetches from the network and writes to the database. Bind the implementation to its interface with a Hilt @Binds module.

Should Room DAO queries return Flow or suspend functions?

Return Flow for queries the UI observes, since Room re-emits automatically when the table changes. Use suspend functions for one-shot reads and all mutations like inserts, updates, and deletes.

Does Room work in Kotlin Multiplatform commonMain?

Yes, Room has been KMP-stable since version 2.7.0. You need @ConstructedBy on the database, the BundledSQLiteDriver for consistent SQLite versions, setQueryCoroutineContext(Dispatchers.IO), and KSP wired per target platform.

How do I implement offline-first sync in Android?

Use stale-while-revalidate for reads by observing the local database while triggering a background network refresh. For writes, apply the outbox pattern by saving changes locally and syncing them with a WorkManager job that survives process death.

Why should network exceptions not reach the ViewModel?

Letting IOException or HttpException escape forces the ViewModel to import Retrofit and OkHttp types, coupling it to the network implementation. The repository should catch these and map them to sealed domain error types like DataError.

Should database models be named Entity or Cached?

Both conventions are valid. The Entity suffix follows Room convention and ties the name to persistence, while a Cached prefix abstracts the storage mechanism. Match the existing project convention, or default to the Entity suffix.