Monday, 8 January 2018

SQLite DB

Hi all,

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();*/
    hupdb.openDatabase("data/data/com.example.snit/databases/hup", null, SQLiteDatabase.OPEN_READONLY);
    String s="select * from registration";
    Cursor c=hupdb.rawQuery(s, null);
    String val="";
    if(c!=null)
    {
        if(c.moveToFirst())
        {
            do
            {
                    String username=c.getString(1);
                    val=val+username;
                   
            }while(c.moveToNext());
        }
    }
    Toast.makeText(this, val, Toast.LENGTH_LONG).show();
   
}

No comments:

Post a Comment