I'm creating an app for doctor's appointment.. So I want to see the booked appointments records in the listview for different activities with a delete button to delete a specific record..
this is my code for making appointments... that is Appo.java
 package com.example.medilyf;
    
    import android.app.DatePickerDialog;
    import android.content.Intent;
    import android.os.Bundle;
    import android.text.InputType;
    import android.view.View;
    import android.widget.Button;
    import android.widget.CheckBox;
    import android.widget.DatePicker;
    import android.widget.EditText;
    import android.widget.TextView;
    import android.widget.Toast;
    
    import androidx.appcompat.app.AppCompatActivity;
    
    import java.util.Calendar;
    
    
    public class Appo extends AppCompatActivity {
    
    
    
        DatePickerDialog picker;
        EditText eText;
        Button btnGet, confirm, seeappo;
        TextView tvw, text, receiver_msg;
        DBHelper myDB;
        CheckBox android, java, angular, python;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_appo);
    
            tvw = findViewById(R.id.textView1);
            eText = findViewById(R.id.editText1);
            myDB = new DBHelper(Appo.this);
    
            android = findViewById(R.id.checkBox);
            angular = findViewById(R.id.checkBox1);
            java = findViewById(R.id.checkBox2);
            python = findViewById(R.id.checkBox3);
            text = findViewById(R.id.txt);
            Button btn = findViewById(R.id.getbtn);
            receiver_msg =findViewById(R.id.textView5);
            // create the get Intent object
            Intent intent = getIntent();
            String str = intent.getStringExtra("dr_name");
    
            // display the string into textView
            receiver_msg.setText(str);
    
    
            eText.setInputType(InputType.TYPE_NULL);
            eText.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    final Calendar cldr = Calendar.getInstance();
                    int day = cldr.get(Calendar.DAY_OF_MONTH);
                    int month = cldr.get(Calendar.MONTH);
                    int year = cldr.get(Calendar.YEAR);
                    // date picker dialog
                    picker = new DatePickerDialog(Appo.this,
                            new DatePickerDialog.OnDateSetListener() {
                                @Override
                                public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                                    eText.setText(dayOfMonth + "/" + (monthOfYear + 1) + "/" + year);
                                }
                            }, year, month, day);
                    picker.show();
                }
            });
            btnGet = findViewById(R.id.button1);
            btnGet.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    String txt = eText.getText().toString();
                    tvw.setText(txt);
                }
            });
    
            btn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    String result ="";
                    if (android.isChecked()) {
                        result += "\n9:00 - 10:30";
                    }
                    if (angular.isChecked()) {
                        result += "\n10:30 -11:30";
                    }
                    if (java.isChecked()) {
                        result += "\n11:30 -12:30";
                    }
                    if (python.isChecked()) {
                        result += "\n2:00 - 3:00";
                    }
                    text.setText(result);
                }
            });
    
            confirm = findViewById(R.id.confirm);
            confirm.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    String time = text.getText().toString();
                    String date = tvw.getText().toString();
                    if (str.equals("")) {
                        Toast.makeText(Appo.this, "Blank values", Toast.LENGTH_SHORT).show();
                    } else {
                        boolean booking = myDB.insertData2(str, time, date);
                        if (booking) {
                            Toast.makeText(Appo.this, "Booking Confirmed", Toast.LENGTH_SHORT).show();
                        } else {
                            Toast.makeText(Appo.this, "Booking not confirmed", Toast.LENGTH_SHORT).show();
                        }
                    }
                }
            });
    
    
        }
            public void onCheckboxClicked(View view) {
                boolean checked = ((CheckBox) view).isChecked();
                String str="";
                // Check which checkbox was clicked
                switch(view.getId()) {
                    case R.id.checkBox:
                        str = checked?"9:00 - 10:30 Selected":"9:00 - 10:30 Deselected";
                        break;
                    case R.id.checkBox1:
                        str = checked?"10:30 -11:30 Selected":"10:30 -11:30 Deselected";
                        break;
                    case R.id.checkBox2:
                        str = checked?"11:30 -12:30 Selected":"11:30 -12:30 Deselected";
                        break;
                    case R.id.checkBox3:
                        str = checked?"2:00 - 3:00 Selected":"2:00 - 3:00 Deselected";
                        break;
                }
                Toast.makeText(Appo.this, str, Toast.LENGTH_SHORT).show();
        }
    
    }
This is the code for sqlite database... that is DBHelper.java
package com.example.medilyf;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import androidx.annotation.Nullable;
import java.util.ArrayList;
public class DBHelper extends SQLiteOpenHelper {
    public static final String col1="name";
    public static final String col2="username";
    public static final String col3="email";
    public static final String col4="PhoneNo";
    public static final String col5="password";
    public static final String NAME = "name";
    public static final String PHONE = "phone";
    public static final String col6="Appointment_id ";
    public static final String col7="full_Name ";
    public static final String col9="Doc_name ";
    public static final String col12="ATime ";
    public static final String col8="Phone_Number";
    public DBHelper(@Nullable Context context) {
        super(context,"Login.db",null,1);
    }
    @Override
    public void onCreate(SQLiteDatabase myDB) {
        myDB.execSQL("create Table users(name Text, username Text primary key, email Text, PhoneNo Text, password Text)");
        myDB.execSQL("create table appo(Dr Text,time Text, date Text)");
    }
    @Override
    public void onUpgrade(SQLiteDatabase myDB, int oldVersion, int newVersion) {
        myDB.execSQL("Drop Table if exists users");
        myDB.execSQL("Drop Table if exists appo");
    }
    public boolean insertData(String name, String username, String email, String PhoneNo, String password){
        SQLiteDatabase myDB = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(col1,name);
        contentValues.put(col2,username);
        contentValues.put(col3,email);
        contentValues.put(col4,PhoneNo);
        contentValues.put(col5,password);
        long result = myDB.insert("users",null,contentValues);
        return result != -1;
    }
    public boolean insertData2(String Dr, String time, String date){
        SQLiteDatabase myDB = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put("Dr",Dr);
        contentValues.put("time",time);
        contentValues.put("date",date);
        long result = myDB.insert("appo",null,contentValues);
        return result != -1;
    }
    public boolean checkusername(String username){
        SQLiteDatabase myDB = this.getWritableDatabase();
        Cursor cursor = myDB.rawQuery("select * from users where username = ?", new String[] {username});
        return cursor.getCount() > 0;
    }
    public boolean checkusernamepassword(String username, String password){
        SQLiteDatabase myDB = this.getWritableDatabase();
        Cursor cursor = myDB.rawQuery("select * from users where username = ? and password = ?", new String[] {username,password});
        return cursor.getCount() > 0;
    }
}
Can anyone help me with the code to retrieve and display the records of the appointment for another activity in list view..???
 
    