I tried to use this code in my DBHandler class
public int getPointsCount() {
        String countQuery = "SELECT * FROM " + TABLE_STUDENTS;
        SQLiteDatabase db = this.getReadableDatabase();
        Cursor cursor = db.rawQuery(countQuery, null);
        cursor.close();
        return cursor.getCount();
    }
and I used this call in a button in main Activity, but it causes my app to crash when I click the Button
callButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
             int cn =  countStudents();
                studentNumberText.setText(cn);
            }
        });
public int countStudents (){
        DBHandler dbHandler = new DBHandler(this, null, null, 1);
        int c = dbHandler.getPointsCount();
        return c;
    }
 
     
     
    