samedi 21 février 2015

How to put and get the current date by using simple database

Since i'm the beginner and don't know how to insert and get the current date by using database.


For insert database, i have to use button for adding the information.There are the fully code.



public void Badd_Click(View view){
db.execSQL("INSERT INTO Demo (event, venue, amount, textView) VALUES ('" + tEvent.getText().toString() + "'," + "'" + tLocation.getText().toString() + "'," + "'" + tAmount.getText().toString() +"' )");
Toast.makeText(this, "Create record successfully...", Toast.LENGTH_SHORT).show();
}


For showing the database information, also i have to use button to do it.



public void Btnshow_Click(View view){
String str = "";
Cursor c = db.rawQuery("SELECT * FROM "+DATABASE_TABLE,null);
c.moveToFirst();
for(int i = 0; i<c.getCount();i++){
str+="ID: "+c.getString(0)+"\n";
str+="Name : "+c.getString(1)+"\n";
str+="Location : "+c.getString(2)+"\n";
str+="Amount : "+c.getString(3)+"\n\n";
c.moveToNext();
}


I searching many solution but i cannot to do it successfully. Please help :(


Aucun commentaire:

Enregistrer un commentaire