Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

how to delete event from calendar with event SQL

package com.example.test1;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.CalendarView;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    private mySQLiteDBHandler dbHandler;
    private EditText editText;
    private CalendarView calendarView;
    private String selectedDate;
    private SQLiteDatabase sqLiteDatabase;

    protected void onCreate(Bundle savedInstanceState) {

        editText = findViewById(R.id.editText);
        calendarView = findViewById(R.id.calendarView);

        calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
            public void onSelectedDayChange(@NonNull CalendarView view, int year, int month, int dayOfMonth) {
                selectedDate = Integer.toString(year) + Integer.toString(month) + Integer.toString(dayOfMonth);
        try {
            dbHandler = new mySQLiteDBHandler(this, "CalendarDatabase", null, 1);
            sqLiteDatabase = dbHandler.getWritableDatabase();
            sqLiteDatabase.execSQL("CREATE TABLE EventCalendar(Date TEXT, Event TEXT)");
        catch (Exception e){
    public void InsertDatabase (View view){
        ContentValues contentValues = new ContentValues();
    public void ReadDatabase(View view){
        String query = "Select Event from EventCalendar where Date =" +selectedDate;
        try {
            Cursor cursor = sqLiteDatabase.rawQuery(query,null);
        catch (Exception e){
package com.example.test1;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class mySQLiteDBHandler extends SQLiteOpenHelper {
    public mySQLiteDBHandler(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);

    public void onCreate(SQLiteDatabase db) {


    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {


im making a simple calendar with event but i realize that after type something on certain day i couldn't erase it nor change it. it will stay whatever it was saved as the first time.
And also im planning to make the save button open a new activity to insert detail and save into a note in  another activity. How do i do that?

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now