android-data-layer

Clarify Android data layer architecture and repository patterns with Retrofit and Room.

Updated Dec 4, 2025
One-click install
npx skills add https://github.com/thinhtt264/Snaplet-App --skill android-data-layer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: android-data-layer
Source: https://github.com/thinhtt264/Snaplet-App/tree/main/.cursor/skills/android-data-layer
Command: npx skills add https://github.com/thinhtt264/Snaplet-App --skill android-data-layer

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps Android developers navigate the Data Layer and Repository patterns, clarifying when to use remote API repositories vs local Room-based repositories and how to structure RepositoryImpls, DAOs, and data models. It provides guidance on choosing architecture for API calls, database access, and data flow in an Android app.

Core Features & Use Cases

  • Clarifies two primary Data Layer patterns: repository-remote (API calls with Retrofit, safeApiCall, ApiResult) and repository-room (Room DAO, local database).
  • Provides guidance on DI bindings for repositories with Hilt, including interface ← impl binding.
  • Covers offline-first scenarios and how to orchestrate API + DAO in a single Impl.
  • Use cases include starting new features, refactoring legacy code, and ensuring testability.

Quick Start

Design a data layer skeleton for a feature using both repository-remote and repository-room patterns.

Frequently Asked Questions about android-data-layer

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

FAQPage Schema
How do I structure an Android data layer with repository pattern and Room?

An Android data layer with repository pattern uses a repository-room approach where a RepositoryImpl wraps Room DAOs for local database access, defining interfaces and implementations to abstract data source interactions and improve testability.

What is the best way to handle Retrofit API calls in an Android repository?

Handling Retrofit API calls in an Android repository uses a repository-remote pattern, wrapping requests in safeApiCall to return ApiResult objects, and exposing them through Kotlin Suspend functions or Flow for safe asynchronous data fetching.

When do I need offline-first architecture in my Android data layer?

You need offline-first architecture when orchestrating API and local database access in a single RepositoryImpl, allowing the Android data layer to fetch from the remote API via Retrofit while caching responses locally using Room DAOs.

How do I bind repository interfaces to implementations using Hilt DI in Android?

Binding repository interfaces to implementations using Hilt DI in Android involves configuring dependency injection modules to map repository interfaces directly to their concrete RepositoryImpl classes for remote API or Room database access.

Repository-remote vs repository-room: which pattern should I choose for my Android feature?

Choose repository-remote for features primarily fetching data via Retrofit API calls, and repository-room for features relying on local Room database persistence, selecting based on whether your data source is remote or local.