Tuesday, 6 November 2018

Login logic in Android using SQLite DB

Hi All,
Use this code to impliment login logic in Android using SQLite
Use the below function 'HUP1(View view)' in the click of a Button.

public void HUP1(View view)

{
      
       SQLiteDatabasehupdb;
       hupdb=this.openOrCreateDatabase("hup", MODE_PRIVATE, null);
       hupdb.openDatabase("data/data/com.example.hupdb1/databases/hup", null, SQLiteDatabase.OPEN_READONLY);
       String s="select * from registration where username=’admin’ and password=’admin’";
       Cursor c=hupdb.rawQuery(s, null);
       if(c!=null)
       {
              if(c.moveToFirst())
              {
              do
              {
                     String username=c.getString(0);
                     String abc=c.getString(1);

                     //write Intent code here

              }while(c.moveToNext());
              }//if
}//if
//Write Toast message here showing invalid login

}

No comments:

Post a Comment