Advertisement
k4u5h4L

Untitled

Nov 29th, 2021
556
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1. package com.example.database;
  2.  
  3. import android.os.Bundle;
  4. import android.view.View;
  5. import android.widget.Button;
  6. import android.widget.EditText;
  7. import android.widget.Toast;
  8.  
  9. import androidx.appcompat.app.AppCompatActivity;
  10.  
  11. public class MainActivity extends AppCompatActivity {
  12.  
  13.     @Override
  14.     protected void onCreate(Bundle savedInstanceState) {
  15.         super.onCreate(savedInstanceState);
  16.         setContentView(R.layout.activity_main);
  17.         EditText edtEmpName = findViewById(R.id.edtName);
  18.         EditText edtDesig = findViewById(R.id.edtDesig);
  19.         EditText edtSalary = findViewById(R.id.edtSalary);
  20.         Button btnSave = findViewById(R.id.btnSave);
  21.         Database1 dbh= new Database1(getApplicationContext());
  22.         btnSave.setOnClickListener(new View.OnClickListener() {
  23.             @Override
  24.             public void onClick(View view) {
  25.                 Employee objEmp = new Employee(edtEmpName.getText().toString(),edtDesig.getText().toString(),Integer.parseInt(edtSalary.getText().toString()));
  26.                 if(dbh.InsertEmployee(objEmp))
  27.                 Toast.makeText(getApplicationContext(),"Record inserted successfully",Toast.LENGTH_LONG).show();
  28.                 else
  29.                 Toast.makeText(getApplicationContext(),"Record not inserted",Toast.LENGTH_LONG).show();
  30.  
  31.             }
  32.         });
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement