android-data-persistence

android-data-persistence is a skill for Claude Code from GuillemRoca/agent-skills-android. It costs 41 tokens per session (2,464 once invoked), scanned A, original, MIT.

Guidance for storing Android app data locally, including structured records, preferences, and data used when the network is unavailable. It covers Room, DataStore, migrations, pagination, and repositories that separate storage from the rest of the app.

In plain words
What is it for?
Adding Room databases and migrations, storing settings with DataStore, building offline-first behavior, paging through large data sets, and organizing data access with repositories.
Why use it?
Apps need data to survive restarts and often need to remain useful without a connection. Clear storage choices also make database changes and large data sets easier to manage safely.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the agent-skills-android plugin — 30 skills, 8 commands, 3 agents shipped together

Good fit Adding Room databases and migrations, storing settings with DataStore, building offline-first behavior, paging through large data sets, and organizing data access with repositories.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/guillemroca/agent-skills-android/android-data-persistence
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add GuillemRoca/agent-skills-android --skill android-data-persistence
Clone the repo
git clone --depth 1 https://github.com/GuillemRoca/agent-skills-android

Made for: Claude Code.

Or install agent-skills-android, the plugin that ships this one along with the rest of its 30 skills, 8 commands, 3 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for android-data-persistence

README.md
[![agentmods](https://agentmods.dev/badge/skills/guillemroca/agent-skills-android/android-data-persistence/github.svg)](https://agentmods.dev/skills/guillemroca/agent-skills-android/android-data-persistence)
Your own site
<a href="https://agentmods.dev/skills/guillemroca/agent-skills-android/android-data-persistence"><img src="https://agentmods.dev/badge/skills/guillemroca/agent-skills-android/android-data-persistence/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for android-data-persistence

Your own site · 80×15
<a href="https://agentmods.dev/skills/guillemroca/agent-skills-android/android-data-persistence"><img src="https://agentmods.dev/badge/skills/guillemroca/agent-skills-android/android-data-persistence.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 41 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,464 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00041 $0.02464
Opus 5.5 $0.00016 $0.00986
Sonnet 5.5 $0.00008 $0.00493
Haiku 4.5 $0.00004 $0.00246

Measured 1mo ago against content hash 4914ec3091a1, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

android-data-persistence scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/android-data-persistence/SKILL.md · 366 lines

How it starts

The opening of the file, as written. The whole thing — 366 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Android Data Persistence

Overview

Reliable data persistence is critical for Android apps. This skill covers Room (SQLite abstraction), DataStore (key-value and proto), offline-first architecture, Paging3 for large datasets, and the repository pattern that abstracts data sources from the rest of the app.

When to Use

  • Setting up or modifying a Room database
  • Writing database migrations
  • Implementing offline-first data access
  • Adding pagination for large datasets
  • Choosing between Room, DataStore, and SharedPreferences
  • Implementing the repository pattern

Skip when: Data is purely in-memory or comes only from a remote API with no caching.

Data Storage Decision Guide

Requirement Solution
Structured data with relations Room
User preferences (key-value) DataStore (Preferences)
Typed settings with schema DataStore (Proto)
Large datasets with pagination Room + Paging3
Simple flags or tokens DataStore (Preferences)
Never use SharedPreferences (for new code)

Core Process

Step 1: Room Setup

  1. Define entities:
@Entity(
    tableName = "tasks",
    indices = [Index(value = ["created_at"])],
)
data class TaskEntity(
    @PrimaryKey
    val id: String,
    @ColumnInfo(name = "title")
    val title: String,
    @ColumnInfo(name = "description")
    val description: String?,
    @ColumnInfo(name = "completed")
    val completed: Boolean = false,
    @ColumnInfo(name = "created_at")
    val createdAt: Long = System.currentTimeMillis(),
    @ColumnInfo(name = "updated_at")
    val updatedAt: Long = System.currentTimeMillis(),
)
  1. Define DAOs:
@Dao
interface TaskDao {
    @Query("SELECT * FROM tasks ORDER BY created_at DESC")
    fun observeAll(): Flow<List<TaskEntity>>

    @Query("SELECT * FROM tasks WHERE id = :taskId")
    suspend fun getById(taskId: String): TaskEntity?

    @Query("SELECT * FROM tasks WHERE completed = :completed ORDER BY created_at DESC")
    fun observeByStatus(completed: Boolean): Flow<List<TaskEntity>>

    @Upsert
    suspend fun upsert(task: TaskEntity)

    @Upsert
    suspend fun upsertAll(tasks: List<TaskEntity>)

    @Query("DELETE FROM tasks WHERE id = :taskId")
    suspend fun deleteById(taskId: String)

    @Query("DELETE FROM tasks WHERE completed = 1")
    suspend fun deleteCompleted()

    @Transaction
    suspend fun replaceAll(tasks: List<TaskEntity>) {
        deleteAll()
        upsertAll(tasks)
    }

    @Query("DELETE FROM tasks")
    suspend fun deleteAll()
}

Read the full file on GitHub · 366 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 366 lines · 41 tokens per session scan A 4914ec3091a1

Subscribe to this mod's changes

android-data-persistence is a skill published in the GitHub repository GuillemRoca/agent-skills-android (4 stars, last pushed 21d ago), licensed MIT. It adds 41 tokens to every session and 2,464 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

sqlite-to-fast-sql

Migrates SQLite and SQL-style Capacitor storage (@capacitor-community/sqlite, cordova-sqlite-storage, @ionic/storage with a SQLite driver, TypeORM/Drizzle/Kysely capacitor drivers, and other bridge-based SQL plugins) to @capgo/capacitor-fast-sql. Use when replacing createConnection/open/query/run/executeSet calls…

Cap-go/capgo-skills · 206 tokens

couchbase

Expert Couchbase NoSQL assistance covering N1QL/SQL++ queries, memory-first caching, document scopes, and cross-datacenter replication (XDCR). Use when building ultra-low latency JSON document platforms.

G1Joshi/Agent-Skills · 46 tokens

sqlite

Expert SQLite embedded database assistance covering WAL mode, PRAGMA tuning, full-text search (FTS5), and concurrency. Use when building desktop/mobile apps, local databases, or high-performance embedded systems.

G1Joshi/Agent-Skills · 42 tokens

swiftdata

Implement, review, or improve data persistence using SwiftData. Use when defining @Model classes with @Attribute, @Relationship, @Transient, @Unique, or @Index; when querying with @Query, #Predicate, FetchDescriptor, or SortDescriptor; when configuring ModelContainer and ModelContext for SwiftUI or background work…

The-Artificer-of-Ciphers-LLC/skills-from-the-artificer · 106 tokens

couchdb

Expert Apache CouchDB assistance covering HTTP REST APIs, Mango queries, conflict resolution, and offline-first mobile sync. Use when building multi-master replicated apps or PouchDB browser synchronization.

G1Joshi/Agent-Skills · 40 tokens

offline-first-expert

Expert guidance for offline-first KMP and Android architectures using Store5, Room, SQLDelight, Ktor. Always trigger this skill when designing repositories, databases, caching, offline sync, Fetchers, SourceOfTruth, Updaters, Bookkeepers.

JosephSanjaya/skills · 57 tokens