Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6558341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:11:15+00:00 2026-05-25T13:11:15+00:00

Actually i am get stuck in a big problem..I have created an app from

  • 0

Actually i am get stuck in a big problem..I have created an app from which i can save event in my device calendar..Now when i save new events from my app in my device calendar it will always delete the events save previously by my app and save a new event and so on..so all works fine..now the big problem is that while deleting it will delete all the events of the calendar that are present in the device calendar including the events that are save by my app..so what i want is to delete only that event that are put by my app while inserting new event from my app not that are already present or which are directly assigned by me in device calendar..so can anyone please help me out to resolve this problem..the code i have use for inserting and deleting are..

    Resources res = c.getResources();

    Uri EVENTS_URI = Uri.parse("content://com.android.calendar/" + "events");

    Uri REMINDERS_URI = Uri.parse("content://com.android.calendar/" + "reminders");

    ContentResolver cr = c.getContentResolver();

    Uri uri= ContentUris.withAppendedId(EVENTS_URI, 1);
    deleteEvent(cr, Resources res = c.getResources();

    Uri EVENTS_URI = Uri.parse("content://com.android.calendar/" + "events");

    Uri REMINDERS_URI = Uri.parse("content://com.android.calendar/" + "reminders");

    ContentResolver cr = c.getContentResolver();

    //Deleting event from device calendar before saving new event
    deleteEvent(cr, EVENTS_URI, 1);

     //saving new data to calendar
    ContentValues values = new ContentValues();
    values.put("calendar_id", 1);
    values.put("title", str);
    values.put("description", m_strDescription);                    
    values.put("dtstart", cal.getTimeInMillis()); 
    values.put("dtend", cal.getTimeInMillis()); 
    values.put("hasAlarm", 1);
        Uri event = cr.insert(EVENTS_URI, values);

    values = new ContentValues();
    values.put("event_id", Long.parseLong(event.getLastPathSegment()));
    values.put("method", 1);
    values.put("minutes", 10);
    cr.insert(REMINDERS_URI, values);

Functions for deleting event

private void deleteEvent(ContentResolver resolver, Uri eventsUri, int calendarId) 
{
    Cursor cursor;
    if (android.os.Build.VERSION.SDK_INT <= 7) 
    { 
        cursor = resolver.query(eventsUri, new String[]{ "_id" }, "Calendars_id=" + calendarId, null, null);
    } 
    else 
    { 
        cursor = resolver.query(eventsUri, new String[]{ "_id" }, "calendar_id=" + calendarId, null, null);
    }
    while(cursor.moveToNext()) 
    {
        long eventId = cursor.getLong(cursor.getColumnIndex("_id"));
        resolver.delete(ContentUris.withAppendedId(eventsUri, eventId), null, null);
    }
    cursor.close();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:11:16+00:00Added an answer on May 25, 2026 at 1:11 pm

    The code you are using is deleting EVERY event: you need to save the ID of the event you create and only delete that one event. When you do this:

    cr.insert(REMINDERS_URI, values);
    

    change that to this:

    Uri u = cr.insert(REMINDERS_URI, values);
    

    This will save the URI of the event you create. You can then pass that URI into your deleteEvent method to only delete that one event, rather than all events.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page which always get stuck only in chrome and safari. The
What program can I use to decompile a class file? Will I actually get
Does anybody know where I can get a free web crawler that actually works
I am again stuck in php regex part of my app :( Actually I
I have been stuck with this issue now all morning. I actually saw this
For the past 2 days I've been stuck on a violation which I can't
Say you have a method that could potentially get stuck in an endless method-call
Ok, I'm a bit stuck on this one, can I actually do what I'm
There were a lot of promises and hopes, but did MS actually get around
I get the error changes not allowed when unmanaged debugging is enabled Actually I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.