Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
new-silvermoon avatar

Android Data Layer

  • 2 installs
  • 910 repo stars
  • Updated July 27, 2026
  • new-silvermoon/awesome-android-skills

Implements the Android data layer with the repository pattern, Room for local storage, and Retrofit for remote data, using offline-first single-source-of-truth synchronization.

About

Coordinates local (Room) and remote (Retrofit) data behind repositories that act as the single source of truth with offline-first sync. A developer uses it when building the data layer of an Android app or wiring caching and refresh logic.

  • Repository as single source of truth exposing a Room Flow
  • Offline-first sync via refresh-then-insert into the local DB

Android Data Layer by the numbers

  • 2 all-time installs (skills.sh)
  • Ranked #888 of 1,039 Mobile Development skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/new-silvermoon/awesome-android-skills --skill android-data-layer

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs2
repo stars910
Last updatedJuly 27, 2026
Repositorynew-silvermoon/awesome-android-skills

What it does

Implements the Android data layer with the repository pattern, Room for local storage, and Retrofit for remote data, using offline-first single-source-of-truth synchronization.

Files

SKILL.mdMarkdownGitHub ↗

Android Data Layer & Offline-First

Instructions

The Data Layer coordinates data from multiple sources.

1. Repository Pattern

  • Role: Single Source of Truth (SSOT).
  • Logic: The repository decides whether to return cached data or fetch fresh data.
  • Implementation:
    class NewsRepository @Inject constructor(
        private val newsDao: NewsDao,
        private val newsApi: NewsApi
    ) {
        // Expose data from Local DB as the source of truth
        val newsStream: Flow<List<News>> = newsDao.getAllNews()

        // Sync operation
        suspend fun refreshNews() {
            val remoteNews = newsApi.fetchLatest()
            newsDao.insertAll(remoteNews)
        }
    }

2. Local Persistence (Room)

  • Usage: Primary cache and offline storage.
  • Entities: Define @Entity data classes.
  • DAOs: Return Flow<T> for observable data.

3. Remote Data (Retrofit)

  • Usage: Fetching data from backend.
  • Response: Use suspend functions in interfaces.
  • Error Handling: Wrap network calls in try-catch blocks or a Result wrapper to handle exceptions (NoInternet, 404, etc.) gracefully.

4. Synchronization

  • Read: "Stale-While-Revalidate". Show local data immediately, trigger a background refresh.
  • Write: "Outbox Pattern" (Advanced). Save local change immediately, mark as "unsynced", use WorkManager to push changes to server.

5. Dependency Injection

  • Bind Repository interfaces to implementations in a Hilt Module.
    @Binds
    abstract fun bindNewsRepository(impl: OfflineFirstNewsRepository): NewsRepository

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.