android-data-and-concurrency-kotlin

Implements Kotlin Coroutines, Flow, Retrofit, and Room data-layer patterns for Android apps.

Updated Jun 13, 2026
One-click install
npx skills add https://github.com/22Teikk/22Teikk-Agent-Skills-Hub --skill android-data-and-concurrency-kotlin-22teikk
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: android-data-and-concurrency-kotlin
Source: https://github.com/22Teikk/22Teikk-Agent-Skills-Hub/tree/main/packs/android/skills/android-data-and-concurrency-kotlin
Command: npx skills add https://github.com/22Teikk/22Teikk-Agent-Skills-Hub --skill android-data-and-concurrency-kotlin-22teikk

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building the data layer of an Android app involves many concurrency pitfalls: blocking the main thread, leaking flow collections, mishandling Room migrations, and losing numeric precision. This Skill provides concrete Kotlin patterns and guardrails for coroutines, Flow, Retrofit, Kotlin Serialization, and Room so the data layer stays thread-safe and lifecycle-aware. ## Core Features & Use Cases - Coroutines & Dispatchers: Enforces viewModelScope usage and Dispatchers.IO for network and database work, avoiding runBlocking and GlobalScope. - Reactive Streams: Guides Room DAOs returning Flow, correct StateFlow vs SharedFlow selection, and lifecycle-safe collection with collectAsStateWithLifecycle(). - Networking & Serialization: Shows Retrofit interfaces with suspend functions and DTOs annotated for Kotlin Serialization. - Room Guardrails: Flags exportSchema = false without migrations as a production blocker and forbids storing money as Double/Float. - Use Case: When implementing a repository that fetches tasks from a REST API, caches them in Room, and exposes them to Compose UI as a lifecycle-aware StateFlow, this Skill supplies the correct code patterns and a verification checklist. ## Quick Start Ask the agent to implement a Room-backed repository with Retrofit networking and Flow-based state exposure for a Kotlin Android feature, then review it against the data-layer guardrails.

Frequently Asked Questions about android-data-and-concurrency-kotlin

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

FAQPage Schema
How do I use Kotlin Coroutines with Retrofit and Room in Android?▼

Mark Retrofit service methods and Room DAO methods as suspend functions, then call them inside withContext(Dispatchers.IO) in your repository. Launch coroutines from viewModelScope in the ViewModel so work is cancelled when the ViewModel clears.

StateFlow vs SharedFlow in Android: which should I use?▼

Use StateFlow for UI state because it holds an initial value and replays the latest value to new collectors. Use SharedFlow or Channel for one-time events like navigation or toast messages that should not be re-delivered on configuration changes.

Should I use collectAsState or collectAsStateWithLifecycle in Compose?▼

Use collectAsStateWithLifecycle for collecting flows in Compose UI. collectAsState keeps collecting while the app is in the background, wasting CPU and battery, whereas the lifecycle-aware variant pauses collection automatically.

Why does my Room database crash after an app update?▼

Crashes after updates usually come from bumping the database version with exportSchema set to false and no Migration provided. Set exportSchema to true, commit the schema JSON, and write a Migration for every version bump to avoid data loss.

Can I store money values as Double in a Room database?▼

No, storing money as Double or Float causes rounding errors, especially in SUM aggregations. Store amounts as Long minor units such as cents, or use BigDecimal, and verify with an in-memory Room DAO test asserting exact values.

When should I not use this Kotlin concurrency approach?▼

Do not use it for Java codebases or RxJava-based concurrency, which belong to a separate Java-oriented skill. For paging, background sync, or key-value storage, use Paging 3, WorkManager, or DataStore from the official Android libraries instead.