Tuesday, 6 November 2018

Android program to insert into SQLite DB

Hi All,
See the Android program to insert into SQLite DB.


public void hup(View abc)
{
  
    SQLiteDatabase hupdb;
    hupdb=this.openOrCreateDatabase("hup", MODE_PRIVATE, null);
    hupdb.execSQL("CREATE TABLE IF NOT EXISTS REGISTRATION(username text,password text)");
    hupdb.execSQL("insert into registration values('HUP','TAFTKTU')");
    Toast.makeText(this, "Data Inserted HUP", Toast.LENGTH_LONG).show();
    hupdb.close();    
}



NB: Here the values can be taken from text boxes using getText() function instead of 'HUP' and 'TAFTKTU'

No comments:

Post a Comment