A small SQLite library for Android. Create a table, then add, read, update and delete rows in a few chained calls, without writing SQL or a SQLiteOpenHelper of your own.
Version 2.0.0 is rewritten in Kotlin for modern Android, works the same from Java, and adds a few things that make it nicer to use: read every row as a simple list, count rows, and store Long and Double values.
The sample app is a small notes app built with this library.
| Light | Dark |
|---|---|
![]() |
![]() |
- No SQL to write. You describe the columns once, and the library builds the table.
- An
IDcolumn for free. Every table gets an auto-increment primary key. - Chained calls. Add or update a whole row in one line.
- Works from Kotlin and Java.
- Tiny. No extra dependencies, Android 5.0 (API 21) and up.
Add JitPack to your repositories in settings.gradle.kts:
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven("https://jitpack.io")
}
}Add the dependency:
dependencies {
implementation("com.github.p32929:AndroidEasySQL-Library:2.0.0")
}// 1. Create the database and the table once, and keep the object.
val db = EasyDB.init(context, "Notes")
.setTableName("Notes")
.addColumn("Title", "text", "not null")
.addColumn("Body", "text")
.addColumn("Edited", "integer")
.doneTableColumn()
// 2. Add a row
db.addData("Title", "Groceries")
.addData("Body", "Milk and eggs")
.addData("Edited", System.currentTimeMillis())
.doneDataAdding() // true if saved
// 3. Read every row as a list of maps (newest first, ordered by column 3)
val notes = db.getAllRows(3, false)
notes.forEach { println("${it["ID"]}: ${it["Title"]}") }
// 4. Update the row with ID 1
db.updateData("Title", "Shopping").rowID(1)
// 5. Delete the row with ID 1
db.deleteRow(1)EasyDB db = EasyDB.init(context, "Notes")
.setTableName("Notes")
.addColumn("Title", "text", "not null")
.addColumn(new Column("Body", "text"))
.doneTableColumn();
boolean saved = db.addData("Title", "Groceries").addData("Body", "Milk and eggs").doneDataAdding();
List<Map<String, Object>> rows = db.getAllRows();
boolean updated = db.updateData(1, "Shopping").rowID(1);
boolean deleted = db.deleteRow(1);- Set up:
init,setTableName,addColumn,doneTableColumn,getAllColumns. - Add:
addData(column, value)for each column, thendoneDataAdding(). A column can be its name or its number (1 is your first column). - Read:
getAllRows()returns a list of maps.getAllData()andgetAllDataOrderedBy(columnNumber, ascending)return aCursor.getOneRowData(id)andsearchInColumn(column, value, limit)return aCursor, ornullwhen nothing matches. Pass limit-1for every match.matchColumns(columns, values)tells you if a row has all those values.count()returns the number of rows.
- Update:
updateData(column, value)for each column, thenrowID(id). - Delete:
deleteRow(id),deleteRow(column, value)anddeleteAllDataFromTable().
Values can be String, Int, Long, Double or null. Close any Cursor you get back when you are done with it.
Most 1.x code works without changes. A few things are different:
- The minimum Android version is now 5.0 (API 21), up from 4.0.3.
deleteRow(column, value)now returnstruewhen it deleted one or more rows. Before, it returnedfalseif more than one row matched, even though they were deleted.searchInColumnwith a limit of0now returns every match. Before, it returned nothing.getOneRowData(column, value)is deprecated. UsesearchInColumn(column, value, 1).- The library now uses the application context, so it no longer holds on to your Activity.
If you need a version that still supports older Android, keep using 1.4.1.
Using Flutter? The same idea is on pub.dev as easiestdb.
MIT License — Copyright (c) 2018 Fayaz Bin Salam. See LICENSE for the full text.
Contributions are very welcome, thank you! Before you start on a pull request, please open an issue and tell me what you would like to add or change. That way we can agree on it first, and your time is not wasted on something that might not fit. Thanks for helping make AndroidEasySQL-Library better.

