DEV Community

Serhii Boboshko
Serhii Boboshko

Posted on

Building SQLite Apps Faster with Jetpack Compose and Compose Entity

Building SQLite Apps Faster with Jetpack Compose and Compose Entity

Working with persistent storage in Android often follows the same routine:

  • Define SQLite tables.
  • Add DAOs, repositories, and ViewModels.
  • Build UI forms manually.
  • Manage migrations over time.

This approach is repetitive and time-consuming.


The Usual Workflow (Room + Compose)

A standard setup usually requires:

  1. Declaring an Entity.
  2. Writing a Dao.
  3. Creating a Repository.
  4. Implementing a ViewModel.
  5. Designing Composables for forms.
  6. Handling navigation and data persistence manually.

Every project starts here, and the boilerplate adds up quickly.


Compose Entity as an Alternative

Compose Entity provides a higher-level abstraction over Jetpack Compose and SQLite. Its main features include:

  • Automatic CRUD form generation.
  • Predefined repositories and ViewModels.
  • Automatic database migrations.
  • Support for extending generated forms with custom composables.

The result is that a working database + UI setup can be achieved by simply defining the data model.


Example: Defining an Entity

@CeEntity(tableName = "person")
@CeGenerator(
    type = GeneratorType.Reference,
    generationLevel = GenerationLevel.UI,
    hasDetails = true,
    detailsEntityClass = DetailsPersonInfo::class
)
@CeCreateTable(tableName = "person")
data class RefPersones(
    override var id: Long,
    override var date: Long,
    override var name: String,
    override var isMarkedForDeletion: Boolean,
    @CeField(
        type = FieldTypeHelper.NUMBER,
        label = "Age",
        placeHolder = "Select Age"
    )
    var age: Int,
    @CeField(
        related = true,
        relatedEntityClass = RefGroupes::class,
        type = FieldTypeHelper.SELECT,
        extName = "groupe",
        label = "Groupe",
        placeHolder = "Select Groupe of the person"
    )
    var groupeId: Long
) : CommonReferenceEntity(id, date, name, isMarkedForDeletion) {
    override fun toString(): String {
        return "$id: $name"
    }
}
Enter fullscreen mode Exit fullscreen mode

Compose Entity will then:

  • Generate the underlying SQLite table.
  • Create a DAO and repository.
  • Provide a default form for adding, editing, and deleting records.

Database Migrations

Schema evolution is one of the most error-prone parts of working with Room. Compose Entity handles this automatically:

  • Adding fields → generates ALTER TABLE statements.
  • Removing fields → creates a safe copy, transfers the data, and rebuilds the table.
  • Strict version checks prevent silent data corruption.
  • All migrations are tracked in structured history for reliability.

This removes much of the manual work in keeping a schema aligned with your entities.


UI Extensibility

Auto-generated forms provide a functional default, but they are not restrictive. Developers can:

  • Inject custom composables into generated screens.
  • Combine automatic layouts with custom UI when more control is needed.

This makes it possible to balance rapid development with project-specific design.


Key Benefits

  • Boilerplate reduction of up to 90 percent.
  • Projects can be prototyped in minutes.
  • Suitable for quick experiments, internal tools, and production use.

Getting Started

To generate a project with Compose Entity, visit:
https://cetempl.homeclub.top/

You can download a ready-made Android Studio project with your chosen package name and application name. It is fully configured and ready to run.

The main page also includes a manual and several examples to explore.

https://youtu.be/KY_wtlVK8BE

Top comments (0)