I am doing Major Project on my small final year and I am very a new comer to Android plus I am not proficient at codings. I want assist with my login page. I have produced something similar to a database connection java file that is this:

    package one.two;

import java.util.List;

import android.app.ListActivity;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import java.util.ArrayList;

    public class UserDB 
     public String KEY_USERNAME = "Username";
     public  String KEY_PASSWORD = "Password";
     public String KEY_LNAME = "LastName";
     public String KEY_FNAME = "FirstName";

     private static final String DATABASE_NAME = "Users";
     private static final String DATABASE_TABLE = "User";

     private static final int DATABASE_VERSION = 1;

     private static Context context;

     private static DatabaseHelper DBHelper;
     private static SQLiteDatabase db;

     public UserDB(Context ctx)
      this.context = ctx;
      DBHelper = new DatabaseHelper(context);

     private static class DatabaseHelper extends SQLiteOpenHelper
      DatabaseHelper(Context context)
       super(context, "Users", null, 1);

      public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)

      public void onCreate(SQLiteDatabase db)
     }//end DatabaseHelper

     // ---opens the database---
     public UserDB open() throws SQLException
      db = DBHelper.getWritableDatabase();
      return this;

     // ---closes the database---
     public void close()


I have already produced a database for customers using SQLite. The database title is Customers and also the table is known as User. The records within the table are Username, Password, LastName, FirstName. I have placed one user's info in to the database. The issue is I don't know whether my UserDB.java is correct.

And I have also produced login.java. Hardcoded Login page:

    package one.two;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.TextView;

public class Login extends Activity implements OnClickListener{

 UserDB db = new UserDB(this);
/** Called when the activity is first created. */

 private EditText etUsername;
 private EditText etPassword;
 private Button btnLogin;
 //private Button btnRegister;
 private TextView lblResult;


    public void onCreate(Bundle savedInstanceState) {


     // Get the EditText and Button References
        etUsername = (EditText)findViewById(R.id.usernametxt);
        etPassword = (EditText)findViewById(R.id.passwordtxt);
        btnLogin = (Button)findViewById(R.id.btnLogin);
        //btnRegister = (Button)findViewById(R.id.btnRegister);
        lblResult = (TextView)findViewById(R.id.msglbl);

        //Cursor c = (Cursor) db.getAllTitles();

        Button btnArrival = (Button) findViewById(R.id.btnRegister);

    // Set Click Listener
    btnLogin.setOnClickListener(new OnClickListener() {
 public void onClick(View v) {
  // Check Login
  String username = etUsername.getText().toString();
  String password = etPassword.getText().toString();

  if(username.equals("guest") && password.equals("guest")){
   lblResult.setText("Login successful.");
  } else {
   lblResult.setText("Login failed. Username and/or password doesn't match.");


    public void onClick(View v)
   Intent intent = new Intent(this, DatabaseActivity.class);


So I wish to understand how I ought to apply the database connection around the login.java. Must I place database connection something similar to db.Open()? I analyzed ASP.Internet a couple of several weeks back and that i type of forget the majority of what I have learnt.

Just how must i open the database connection on login.java and just how to check on with database if the user makes its way into the best account information?

You gotta search on the internet for additional database good examples.

A good web site could be anddev.org