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 4617562
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:08:30+00:00 2026-05-22T02:08:30+00:00

I want to get calendar event updates (when a new event is added or

  • 0

I want to get calendar event updates (when a new event is added or an existing event is deleted ) on android 2.2 devices ?
i am beginner so tell me step by step solution for this..

  • 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-22T02:08:30+00:00Added an answer on May 22, 2026 at 2:08 am

    This code might help you 🙂

    public class myCalendar 
    {
    
    static Cursor cursor;
    
    public static void readCalendar(Context context) {
    
        ContentResolver contentResolver = context.getContentResolver();
    
        // Fetch a list of all calendars synced with the device, their display names and whether the
        // user has them selected for display.
    
    
        cursor = contentResolver.query(Uri.parse("content://com.android.calendar/calendars"),
                    (new String[] { "_id", "displayName", "selected"}), null, null, null);
    
    
        HashSet<String> calendarIds = new HashSet<String>();
    
        try
        {
            System.out.println("Count="+cursor.getCount());
            if(cursor.getCount() > 0)
            {
                System.out.println("the control is just inside of the cursor.count loop");
            while (cursor.moveToNext()) {
    
                 String _id = cursor.getString(0);
                 String displayName = cursor.getString(1);
                 Boolean selected = !cursor.getString(2).equals("0");
    
                System.out.println("Id: " + _id + " Display Name: " + displayName + " Selected: " + selected);
                calendarIds.add(_id);
            }
        }
        }
        catch(AssertionError ex)
        {
            ex.printStackTrace();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    
    
        // For each calendar, display all the events from the previous week to the end of next week.        
        for (String id : calendarIds) {
            Uri.Builder builder = Uri.parse("content://com.android.calendar/instances/when").buildUpon();
            //Uri.Builder builder = Uri.parse("content://com.android.calendar/calendars").buildUpon();
            long now = new Date().getTime();
    
            ContentUris.appendId(builder, now - DateUtils.DAY_IN_MILLIS * 10000);
            ContentUris.appendId(builder, now + DateUtils.DAY_IN_MILLIS * 10000);
    
            Cursor eventCursor = contentResolver.query(builder.build(),
                    new String[]  { "title", "begin", "end", "allDay"}, "Calendars._id=" + 1,
                    null, "startDay ASC, startMinute ASC");
    
            System.out.println("eventCursor count="+eventCursor.getCount());
            if(eventCursor.getCount()>0)
            {
    
                eventCursor.moveToFirst();
    
                while (eventCursor.moveToNext())
                {
                    Object beg_date,beg_time,end_date,end_time;  
    
                    final String title = eventCursor.getString(0);
                    final Date begin = new Date(eventCursor.getLong(1));
                    final Date end = new Date(eventCursor.getLong(2));
                    final Boolean allDay = !eventCursor.getString(3).equals("0");
    
            /*  System.out.println("Title: " + title + " Begin: " + begin + " End: " + end +
                        " All Day: " + allDay);
            */  
                    System.out.println("Title:"+title);
                    System.out.println("Begin:"+begin);
                    System.out.println("End:"+end);
                    System.out.println("All Day:"+allDay);
    
                    System.out.println("only date begin of events="+begin.getDate());
                    System.out.println("only begin time of events="+begin.getHours() + ":" +begin.getMinutes() + ":" +begin.getSeconds());
    
                    System.out.println("only date begin of events="+end.getDate());
                    System.out.println("only begin time of events="+end.getHours() + ":" +end.getMinutes() + ":" +end.getSeconds());
    
                    beg_date = begin.getDate();
                    beg_time = begin.getHours()+":"+begin.getMinutes();
    
                    end_date = end.getDate();
                    end_time = end.getHours()+":"+end.getMinutes();
    
    
    
    
    
                }
            }
            break;
        }
    }
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get calendar event last sevendays on android devices ? i am
I want to retrive the data of last added event from android calendar .
I am adding event to android calendar . after inserting event, i want that
What I want: I want to add calendar events in Android 2.2. What I
I want to create calendar. It is working. But if Android version +4.0. it
I am stuck on Google Calendar API on Add event. I want to allow
I am trying to get an event calendar working from json data. I just
I want to get all the Calendars, which are in my GoogleAccount, using the
I want get the time used for a case so I can create an
I want get all of the Geom objects that are related to a certain

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.