• What is Kotlin?

    1. Google announced Kotlin is an official language for android development.Kotlin is flexible and has some cool features and easy to use!
    2. Kotlin is a statically-typed, modern programming language that runs on a Java Virtual Machine (JVM) by compiling Kotlin code into Java byte-code.
    3. Kotlin is free and open to use
    4. It can also be compiled to JavaScript source code to native executable.
    5. Kotlin fully supported in Android Studio 3.0 and higher

    Why Kotlin?

    1. Compatibility: Kotlin is fully compatible with JDK 6, ensuring that Kotlin applications can run on older Android devices with no issues. The Kotlin tooling is fully supported in Android Studio and compatible with the Android build system.

    2. Performance: A Kotlin application runs as fast as an equivalent Java one, thanks to very similar bytecode structure. With Kotlin's support for inline functions, code using lambdas often runs even faster than the same code written in Java.

    3.Interoperability: Kotlin is 100% interoperable with Java, allowing to use all existing Android libraries in a Kotlin application. This includes annotation processing, so databinding and Dagger work too.

    4. Footprint Kotlin has a very compact runtime library, which can be further reduced through the use of ProGuard. In a real application, the Kotlin runtime adds only a few hundred methods and less than 100K to the size of the .apk file.

    What is SQLite?

    1. SQLite is one of the ways of storing data. It is very lightweight database that comes with Android OS.
    2. In Android, integrating SQLite is a tedious task as it needs writing lot of boilerplate code to store simple data. Consider SQLite when your app needs to store simple data objects.
    3. For many applications, SQLite is the app’s backbone whether it’s used directly or via some third-party wrapper. In this tutorial, we will write code in Kotlin and also see how to use SQLite in our app directly.

    Key point to understand regarding SQLite in this project: -

    1. SQLite is RDBMS (Relational Database Management System)
    2. SQLite is written in programming language
    3. SQLite is embedded within the Android Operating System, so you don’t need anything external on Android to use SQLite
    4. To manipulate data (insert, update, delete) in SQLite database – we’ll use SQL (Structured Query Language)

    In this tutorial, we are going to learn how to use SQLite using Kotlin. To really understand the usage of SQLite we will create an app using Kotlin. The App contains simple Login form, Registration form. This app shows how SQLite database operations are performed.

    What is Material Design?

    1. Material Design is a visual language developed by Google which was first introduced with Lollipop OS and since then it has become popular in designing and developing Android Apps.
    2. Material Design is a visual language that synthesizes the classic principles of good design with the innovation of technology and science.

    Follow the below steps to developed the Login and registration form with Kotlin in android studio 3.0 and higher using SQLite:

    Create a new android project.

    1. Add libraries to build.gradle file.

    1. For designing purpose, you can use Material Design.
    2. Add Gradle dependencies libraries in your build.gradle file and rebuilt the project successfully.

        Implementation 'com.android.support:appcompat-v7:27.1.1'
        Implementation 'com.android.support:design:27.1.1'
        Implementation 'com.android.support:cardview-v7:27.1.1'

    2. Update strings.xml located in res->values->string.xml.

    Add the below string values to the string.xml file located in res ⇒ values ⇒ strings.xml.

        <!--App name-->
        <string name="app_name">ToDoListKotlinApp</string>
        <string name="hint_name">Username</string>
        <string name="hint_pass">Password</string>
        <string name="hint_email">Email</string>
        <string name="register_txt">No account yet? Create one</string>
        <string name="registration_text">REGISTER</string>
        <string name="login_text">LOGIN</string>
        <string name="already_login_txt">Already a member? Login</string>
        <!--error message-->
        <string name="error_message_name">Please enter valid name</string>
        <string name="error_message_email">Please enter valid email</string>
        <string name="error_message_password">Please enter valid password</string>
        <string name="error_email_exists">User may already exist</string>
        <!--success message-->
        <string name="success_message">User added successfully</string>
        <string name="login_success_message">User logged successfully</string>

    Please refer below attachment for string.xml file declaration:

    3. Update colors.xml located in res->values->colors.xml.

    Add the below color values to the colors.xml located in res ⇒ values ⇒ colors.xml.

        <color name="colorPrimary">#b71c1c</color>
        <color name="colorPrimaryDark">#7f0000</color>
        <color name="colorAccent">#FF4081</color>
        <color name="df_red">#dc3545</color>
        <color name="df_danger">#dc3545</color>
        <color name="formBg">#f0f0f0</color>
        <color name="black_alpha_75">#bf000000</color>
        <color name="colorText">#ffffffff</color>

    This colors are used in form background, toolbar, actionbar, textview colors.

    4. Update styles.xml located in res->values->styles.xml.

    Add the below style values to the styles.xml located in res ⇒ values ⇒ styles.xml.

        <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
            <item name="colorPrimary">@color/colorPrimary</item>
            <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
            <item name="colorAccent">@color/colorAccent</item>

    Please refer below attachment for style.xml file

    5. Add Logo Image in res->drawable.

    Add logo image to the drawable folder located in res ⇒ drawable.

    Please refer below path to add resource in drawable file.

    6. Create User model class in model package.

    Create a new package named model or you say it as a pojo class and create a Kotlin class named UserModel to maintain single user as an object.

    package com.itw.todolistkotlinapp.model
    class UserModel(val userid: Int = -1, val name: String, val email: String, val pass:  String)

    7. Create DbHelper class in dbmanager package.

    Create a new package named dbmanager and create Kotlin class named DBHelper. Extend this class with SQLiteOpenHelper to manage database creation and version management. I have written methods for database operations.