Android database (p3)- INSERT record example

This tutorial is continuation of part 2 –>

Add a new Activity to the existing project. This Activity is named InsertActivity. The UI is as in the following screenshot.


The UI xml. – available in the sourcecode –>

While onClick of the button, the program will fetch the Malay word, and the English pair provided by the user.

public void onClick(View arg0) {
// TODO Auto-generated method stub
String wmelayu=txtmelayu.getText().toString();
String wenglish=txtenglish.getText().toString();
//kena letak dalam onclick
//-run SELECT command to fetch data from table
String sql;
sql="INSERT INTO melayuenglish (katamelayu, kataeng) VALUES ('"+wmelayu+"','"+wenglish+"');";
String msg="Perkataan baru disimpan, "+sql;
Toast.makeText(getApplicationContext(), msg,Toast.LENGTH_SHORT).show();




Download the complete Source-code here -

No comments:

Post a Comment

Popular Posts