![]() |
VOOZH | about |
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.
To create a new project in the Android Studio, please refer to How to Create a new Project in Android Studio with Jetpack Compose.
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.
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: