Add following code in MainAcitvity class package `in`.eyehunt.sqliteandroidexample Now add following widget in activity_main.xml Its an always good practice you define your string in res/values/strings.xml. Add Button, TextView, EditText widget in MainActivity resource layout.īefore adding, you must add a string in the resource. SQLiteOpenHelper(context, DB_NAME, null, DB_VERSIOM) Step 3. Import Ĭlass DatabaseHandler(context: Context) : You may also want to implement the onDowngrade() or onOpen() methods, but they are not required in this example. Must override the onCreate() and onUpgrade() callback methods. } Step 2. Create DatabaseHandler kotlin class and extend SQLiteOpenHelper Step 1. Create an android project in the android studio (Follow this tutorial: Android First Program in Android Studio kotlin) Step 2. Create a model class (POJO): UsersĬreate a package directory in the root package its good practice to maintain your code.