How to create Login App in Android App in Android Studio | Android App Development For Beginners in Urdu Hindi

Login and Register Android App JAVA and SQLite - Android Mobile Development Urdu Hindi Beginners

Almost every android application contains a login page and signup page. In this tutorial, we will learn how to create a simple login app in any android app using Android Studio with SQLite Database. This article, code example, and video lesson is best for students of Android App Development For Beginners in Urdu & Hindi language. This simple login app will be made in Android Studio and source code will be shared here the implementation of this Simple user registration, signing and signup app will be available on our official GitHub account as well.

This can be used as a student registration app in any android studio project as well. Let’s start with the database code helper file that needed to be created in this project.

Login and Register Android App JAVA and SQLite | Android Mobile Development Urdu Hindi Beginners

In this video did you still demonstrate the live code example to create a simple login and signup application for the Android mobile development course being offered at the undergraduate level in our universities. You can create a simple login and registration application by which the user is offer to sign up in an SQLite database.
Using only four attributes by which we will show you how a user can signup and register the data can be saved in an SQLite database using Android studio simple login and registration on application.

MyDBHelper.java

package com.example.loginapp;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;


import java.util.ArrayList;
import java.util.HashMap;

public class MyDBHelper extends SQLiteOpenHelper {

    public static final String DATABASE_NAME = "MyDBUsers.db";
    public static final String CONTACTS_TABLE_NAME = "tblUsers";
    public static final String COLUMN_ID = "id";
    public static final String COLUMN_NAME = "name";
    public static final String COLUMN_EMAIL = "email";
    public static final String COLUMN_PASS = "password";

    private HashMap hp;

    public MyDBHelper(Context context) {
        super(context, DATABASE_NAME , null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // TODO Auto-generated method stub
        db.execSQL(
                "create table contacts " +
                        "(id integer, name text,email text, password text)"
        );
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // TODO Auto-generated method stub
        db.execSQL("DROP TABLE IF EXISTS contacts");
        onCreate(db);
    }

    public boolean insertUser (int id, String name, String email, String pass) {
        //step 1 database connection and opening in writebale mode
        SQLiteDatabase db = this.getWritableDatabase();
        // step 2 creating contentvalues object container
        ContentValues contentValues = new ContentValues();
        //putting arguments in contentValues object to insert in table
        contentValues.put("id", id);
        contentValues.put("name", name);
        contentValues.put("email", email);
        contentValues.put("place", pass);

        db.insert("tblUsers", null, contentValues);
        return true;
    }

       public Cursor getData(int id) {
        SQLiteDatabase db = this.getReadableDatabase();
        Cursor res =  db.rawQuery( "select * from contacts where id="+id+"", null );
        return res;
    }
}

Signupuser Activity Code

package com.example.loginapp;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class signupUser extends AppCompatActivity {
    Button btnSignup;
    EditText et1,et2,et3,et4;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_signup_user);

        et1 = findViewById(R.id.etuserid);
        et2 = findViewById(R.id.etusername);
        et3 = findViewById(R.id.etemail);
        et4 = findViewById(R.id.etpassword);

        MyDBHelper myDB = new MyDBHelper(this);


        btnSignup = (Button) findViewById(R.id.btnsignup);

        btnSignup.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view)
            {
                // Do something
                int id = Integer.parseInt(et1.getText().toString());  //explicit casting
                String name = et2.getText().toString();
                String email = et3.getText().toString();
                String pass = et3.getText().toString();

                Boolean result = myDB.insertUser(id,name,email,pass);
                if(result==true){
                    Toast.makeText(getApplicationContext(),"User Registered Successfully",Toast.LENGTH_SHORT).show();
                }
            }
        });

    }
}

Author: Habibullah Qamar

Its me Habib Ullah Qamar working as a Lecturer (Computer Sciences) in Pakistan. I have an MS(M.Phil) degree in computer sciences with specialization in software engineering from Virtual University of Pakistan Lahore. I have an experience of more than 15 years in the filed of Computer Science as a teacher. Blog Writing is my passion. I have many blogs, This one is special made with the aim of providing 100% Free online coaching and training to the students of under-graduate and postgraduate classes. Most of the students enrolled in computer sciences, information technology, software engineering and related disciplines find it difficult to understand core concepts of programming and office automation. They find difficult in understanding and solving their assignments.