Usage Docs
DBFlow is a Kotlin SQLite library for Android that makes it ridiculously easy to interact and use databases. Built with Annotation Processing, code use within a DB is fast, efficient, and type-safe. It removes the tedious (and tough-to-maintain) database interaction code, while providing a very SQLite-like query syntax.
Creating a database is as easy as a few lines of code:
@Database(version = 1)
abstract class AppDatabase: DBFlowDatabaseThe @Database annotation generates a DatabaseDefinition which now references your SQLite Database on disk in the file named "AppDatabase.db". You can reference it in code as:
val db = database<AppDatabase>();
// or
database<AppDatabase> { db ->
}To ensure generated code in DBFlow is found by the library, initialize the library in your Application class:
class MyApp : Application {
override fun onCreate() {
super.onCreate()
FlowManager.init(this)
}
}By default, DBFlow generates the GeneratedDatabaseHolder class, which is instantiated once by reflection, only once in memory.
Creating a table is also very simple:
Then to create, read, update, and delete the model:
Last updated
Was this helpful?