VOOZH about

URL: https://www.geeksforgeeks.org/kotlin/how-to-create-and-add-data-to-sqlite-database-in-android-using-jetpack-compose/

⇱ How to Create and Add Data to SQLite Database in Android using Jetpack Compose? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Create and Add Data to SQLite Database in Android using Jetpack Compose?

Last Updated : 23 Jul, 2025

SQLite Database is another data storage available in Android where we can store data in the user’s device and can use it any time when required. In this article we will take a look on How to Create and add data to SQLite Database in Android using Jetpack Compose. 

Step by Step Implementation

Step 1: Create a New Project in Android Studio

To create a new project in the Android Studio, please refer to How to Create a new Project in Android Studio with Jetpack Compose.

Step 2: Creating a new class for performing SQLite database operations. 

Navigate to app>java> {package-name}, Right click on it, New Java/Kotlin class and name it as DBHandler and add the below code to it.

Comments are added in the code to get to know in detail. 


Step 3: Working with MainActivity.kt file. 

Navigate to app>java> {package-name} > MainActivity.kt file and add the below code to it. Comments are added in the code to get to know in detail.

In this file we will creating a composable function that displays 1 text as a title, 4 text fields as input for course details and a button to save the data in database.

MainActivity.kt:


Output:


Comment
Article Tags:

Explore