Android Database
/Android Database
Store data on Android with Room, SQLite or DataStore, including schema, migrations, threading and testing. Use when the app needs persistence.
- Author
- a2heng ↗
- Repository
- android-dev-in-android ↗
- Licence
- MIT
- Last repository change
- 12.11.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 12.11.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Store data on Android with Room, SQLite or DataStore, including schema, migrations, threading and testing. Use when the app needs persistence.
Original author description
Store data on Android with Room, SQLite or DataStore, including schema, migrations, threading and testing. Use when the app needs persistence.
How it works
- Choose
- Room setup
- Rules
- Check dependencies
- Debug on device
SKILL.md preview
---
name: Android Database
description: Store data on Android with Room, SQLite or DataStore, including schema, migrations, threading and testing. Use when the app needs persistence.
---
# Android Database
## Choose
- **DataStore (Preferences/Proto)**: small key-value settings, no schema.
- **Room**: relational data, queries, migrations, Flow support.
- **Raw SQLite**: only for tiny cases or existing code; Room is safer.
## Room setup
```groovy
implementation 'androidx.room:room-runtime:2.6.1'
annotationProcessor 'androidx.room:room-compiler:2.6.1'
// Kotlin: use ksp/kapt matching the Kotlin plugin
```
```kotlin
@Entity data class Note(@PrimaryKey(autoGenerate = true) val id: Long = 0, val text: String)
@Dao interface NoteDao {
@Query("SELECT * FROM Note ORDER BY id DESC") fun all(): Flow<List<Note>>
@Insert suspend fun insert(note: Note): Long
@Delete suspend fun delete(note: Note)
}
@Database(entities = [Note::class], version = 1)
abstract class AppDb : RoomDatabase() {
abstract fun notes(): NoteDao
}
```
## Rules
- Never access the database on the main thread.
- Use `suspend`/`Flow`; Room enforces it for queries.
- Every schema change needs a migration or `fallbackToDestructiveMigration`
only for debug builds.
- Export the schema (`room.schemaLocation`) so migrations are reviewable.
- Test with an in-memory database (`Room.inMemoryDatabaseBuilder`).
- Back up/restore is the app's responsibility; `allowBackup` may be disabled
for token-bearing apps.
## Check dependencies
Room artifacts may not be in the offline cache. Check with a small build; if
missing, ask before `OC_BUILD_ONLINE=1`.
## Debug on device
```sh
adb shell run-as com.example.app ls databases
adb shell run-as com.example.app sqlite3 databases/app.db '.tables'
```
Run adb normally; `auto` sends the whole command (including variables) to proot.
`sqlite3` may not be present on the device; do not depend on it for the app.
Versions
The database has no other skills named Android Database.
Database snapshot: 13.11.2026 · package version c80e478ba514 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100android-room-database-sqlite-orm
Use this skill when persisting local offline data on Android devices using type-safe Room DAOs, entities, and database migrations. - 100android-development
Use when building or reviewing native Android apps with Kotlin, Compose, architecture, Room/DataStore persistence, offline sync, or test-driven development; use mobile-platform-operations for store release work. - 95datastore
Use when persisting key-value preferences or small typed settings on Android or KMP with Jetpack DataStore — Preferences vs Typed (Proto/JSON) vs Room selection, the IOException and corruption-recovery error traps, serializers with corruption handlers, and the KMP factory with… - 100database-management
Implement SQLite database patterns using the database.py interface with complete SQL isolation. MANDATORY for all database projects. Use when working with databases, data persistence, or SQLite. - 90database-quick
Use when the product needs to store data — choosing between JSON/SQLite/Supabase/Postgres, schema design, migrations, seeding, and vector search for RAG. - 90rust-persistence
File and SQLite persistence for Cybercore Rust apps. Use for atomic writes, data directories, SQLite setup, and ordered migrations. Do not invent a second database without approval.