← ClaudeAtlas

android-data-layerlisted

Repositories and data sources per Google's data layer guide: models per layer, main-safety, lifetimes, errors, caching, WorkManager, offline-first sync. Use for repository, data source, Room, DataStore, network, or sync work, and when saves are cancelled on leaving a screen, work must survive process death, network or database models leak past repositories, or the app must work offline.
pablitoarango/android-skills · ★ 3 · Data & Documents · score 74
Install: claude install-skill pablitoarango/android-skills
# Android Data Layer Sources of truth: [Data layer](https://developer.android.com/topic/architecture/data-layer), [Offline-first](https://developer.android.com/topic/architecture/data-layer/offline-first). For offline-first reads, write strategies, synchronization and conflict resolution, read [`offline-first.md`](offline-first.md). ## 1. Responsibilities The data layer holds the app data **and the business logic** that gives it value: - Exposes data to the rest of the app as immutable types. - Centralizes every change to that data. - Resolves conflicts between data sources. - Hides data sources from the rest of the app. ## 2. Structure ``` Repository (public) one per data type; the only entry point ├── XxxLocalDataSource internal; one source each (Room, DataStore, file) └── XxxRemoteDataSource internal; one source each (Retrofit, Firebase) ``` - Create a repository **even for a single data source**. - Each repository defines **one source of truth**. For offline-first data it is the local database. - Each data source works with exactly one source of data. - Name data sources by role, not technology: `NewsRemoteDataSource`, not `NewsRetrofitDataSource`. - Repositories may depend on other repositories when combining data; name such a class `<DataType>Manager` if it only coordinates (`UserManager`). - ViewModels, use cases and composables never inject a DAO, Retrofit service, DataStore or data source. ```kotlin interface NewsRepository { fun getN