package com.example.programmingknowledge.sqliteapp;importandroid.support.v7.app.ActionBarActivity;importandroid.os.Bundle;importandroid.view.Menu;importandroid.view.MenuItem;importandroid.view.View;importandroid.widget.Button;importandroid.widget.EditText;importandroid.widget.Toast;publicclassMainActivityextends ActionBarActivity {
DatabaseHelper myDb;
EditText editName,editSurname,editMarks;
Button btnAddData;@OverrideprotectedvoidonCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myDb =new DatabaseHelper(this);
editName =(EditText)findViewById(R.id.editText_name);
editSurname =(EditText)findViewById(R.id.editText_surname);
editMarks =(EditText)findViewById(R.id.editText_Marks);
btnAddData =(Button)findViewById(R.id.button_add);
AddData();}publicvoidAddData(){
btnAddData.setOnClickListener(new View.OnClickListener(){@OverridepublicvoidonClick(View v){boolean isInserted = myDb.insertData(editName.getText().toString(),
editSurname.getText().toString(),
editMarks.getText().toString());if(isInserted =true)
Toast.makeText(MainActivity.this,"Data Inserted",Toast.LENGTH_LONG).show();else
Toast.makeText(MainActivity.this,"Data not Inserted",Toast.LENGTH_LONG).show();}});}@OverridepublicbooleanonCreateOptionsMenu(Menu menu){// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);returntrue;}@OverridepublicbooleanonOptionsItemSelected(MenuItem item){// Handle action bar item clicks here. The action bar will// automatically handle clicks on the Home/Up button, so long// as you specify a parent activity in AndroidManifest.xml.int id = item.getItemId();//noinspection SimplifiableIfStatementif(id == R.id.action_settings){returntrue;}returnsuper.onOptionsItemSelected(item);}}
package com.example.programmingknowledge.sqliteapp;importandroid.support.v7.app.ActionBarActivity;importandroid.os.Bundle;importandroid.view.Menu;importandroid.view.MenuItem;publicclassMainActivityextends ActionBarActivity {
DatabaseHelper myDb;@OverrideprotectedvoidonCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myDb =new DatabaseHelper(this);}@OverridepublicbooleanonCreateOptionsMenu(Menu menu){// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);returntrue;}@OverridepublicbooleanonOptionsItemSelected(MenuItem item){// Handle action bar item clicks here. The action bar will// automatically handle clicks on the Home/Up button, so long// as you specify a parent activity in AndroidManifest.xml.int id = item.getItemId();//noinspection SimplifiableIfStatementif(id == R.id.action_settings){returntrue;}returnsuper.onOptionsItemSelected(item);}}