How can I compare login data with my SQLite DB in android app..? : I,ve made a simple login app with an SQLite DB. Now I want to compare my login data(username,password) with my DB to proceed, for this what should I do in my loginactivity code. Both login and registration activities are shown.

    \\This is Registration Activity with SQLite DB "DB"

    package com.example.shahxad.myapp;

    import android.content.Intent;
    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.Toast;
    import android.os.Handler;
    public class RegistrationActivity extends AppCompatActivity {
    public SQLiteDatabase DB;
    public EditText username, email, phone, password;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_registration);
    DB = openOrCreateDatabase("DB", MODE_PRIVATE, null);

    DB.execSQL("create table if not exists users(REC_ID INTEGER  PRIMARY KEY         AUTOINCREMENT,NAME varchar(20),EMAIL VARCHAR(20),PHONE integer(10),PASSWORD VARCHAR(20))");
    username = (EditText)findViewById(R.id.username);
    email = (EditText)findViewById(R.id.email);
    phone = (EditText)findViewById(R.id.phone);
    password = (EditText)findViewById(R.id.password);
    Button reg = (Button) findViewById(R.id.reg);
    reg.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String sql = "insert into users(REC_ID,NAME,EMAIL,PHONE,PASSWORD) values(NULL,'" + username.getText().toString() + "','" + email.getText().toString() + "','" + phone.getText().toString() + "','" + password.getText().toString() + "')";
            DB.execSQL(sql);
            Cursor cursor = DB.rawQuery("select * from users", null);
            cursor.moveToLast();
            String result = cursor.getString(0).toString() + cursor.getString(1).toString() + cursor.getString(2).toString() + cursor.getString(3).toString();
            Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG).show();
            Intent intent = new Intent(RegistrationActivity.this, RegSplash.class);
            startActivity(intent);

          }
        });
      }
    }

    \\This is Login Activity (these are two different activities)

    package com.example.shahxad.myapp;

    import android.content.Intent;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;

    public class LoginActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        Button login = (Button) findViewById(R.id.login);
        login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent = new Intent(LoginActivity.this, AppActivity.class);
                startActivity(intent);
            }
        });
      }
    }
    