![]() |
VOOZH | about |
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.
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.
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:
Create a DBHandler.kt class to work with SQLite Database. This time add a new function deleteCourse() to handle deleting data.
Create a kotlin file named CourseModal.kt as a model for each courses.
CourseModal.kt:
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:
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: