VOOZH about

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

⇱ How to Delete Data in SQLite Database in Android using Jetpack Compose? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Delete Data in SQLite Database in Android using Jetpack Compose?

Last Updated : 23 Jul, 2025

In the previous articles, we have seen three operations of CRUD operations such as create, read and update operations in our Android app. In this article, we will take a look at the delete operation for deleting our items stored in the SQLite database in the android application using Jetpack Compose.

What we are going to build in this article?

We will be building a simple application in which we will be deleting the course from our SQLite database in our Android app using Jetpack Compose. A sample video is given at the end to get an idea about what we are going to do in this article. 

Step by Step Implementation

Step 1: Working with MainActivity

Navigate to MainActivity.kt and add the following code to add a new course. This step is already shown in previous articles but it is provided again for convenience.

MainActivity.kt:


Step 2: Create DBHandler class

Create a DBHandler.kt class to work with SQLite Database. This time add a new function deleteCourse() to handle deleting data.


Step 3: Create a model class for each courses

Create a kotlin file named CourseModal.kt as a model for each courses.

CourseModal.kt:


Step 4: Create an activity to view courses

Create a new activity with name ViewCourses and uncheck the Generate Layout file option, since we are using compose. Now, add the following code to the file.

ViewCourses.kt:


Step 5: Create a new activity to update courses

Create a new activity with name UpdateCourse and uncheck the Generate Layout file option, since we are using compose. Now, add the following code to the file. This time, add a new button at the end to delete a single course.

UpdateCourse.kt:


Output:

Comment
Article Tags:

Explore