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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:06:31+00:00 2026-06-13T19:06:31+00:00

Hi I am able to get events using this code cur = null; cr

  • 0

Hi I am able to get events using this code

cur = null;
    cr = getContentResolver();


    // Construct the query with the desired date range.
    Uri.Builder builder = Instances.CONTENT_URI.buildUpon();

    ContentUris.appendId(builder, 0);
    ContentUris.appendId(builder, endMillis);


    // Submit the query
    cur =  cr.query(builder.build(), 
        INSTANCE_PROJECTION, 
        null, 
        null, 
        null);

but as you see I can get only events within the given time duration, but I need all the events (no any time specification excluding repeated events) is this possible ? and how ?
please help me.

cur =  cr.query(Uri.parse("content://com.android.calendar/events"), 
        INSTANCE_PROJECTION, 
        null, 
        null, 
        null);

it gives the error java.lang.IllegalArgumentException:

  • 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-06-13T19:06:32+00:00Added an answer on June 13, 2026 at 7:06 pm

    Try this code…

    public class Utility {
    
        public static ArrayList<String> nameOfEvent = new ArrayList<String>();
        public static ArrayList<String> startDates = new ArrayList<String>();
        public static ArrayList<String> endDates = new ArrayList<String>();
        public static ArrayList<String> descriptions = new ArrayList<String>();
    
        public static ArrayList<String> readCalendarEvent(Context context) {
            Cursor cursor = context.getContentResolver()
                    .query(
                            Uri.parse("content://com.android.calendar/events"),
                            new String[] { "calendar_id", "title", "description",
                                    "dtstart", "dtend", "eventLocation" }, null,
                            null, null);
            cursor.moveToFirst();
            // fetching calendars name
            String CNames[] = new String[cursor.getCount()];
    
            // fetching calendars id
            nameOfEvent.clear();
            startDates.clear();
            endDates.clear();
            descriptions.clear();
            for (int i = 0; i < CNames.length; i++) {
    
                nameOfEvent.add(cursor.getString(1));
                startDates.add(getDate(Long.parseLong(cursor.getString(3))));
                endDates.add(getDate(Long.parseLong(cursor.getString(4))));
                descriptions.add(cursor.getString(2));
                CNames[i] = cursor.getString(1);
                cursor.moveToNext();
    
            }
            return nameOfEvent;
        }
    
        public static String getDate(long milliSeconds) {
            SimpleDateFormat formatter = new SimpleDateFormat(
                    "dd/MM/yyyy hh:mm:ss a");
            Calendar calendar = Calendar.getInstance();
            calendar.setTimeInMillis(milliSeconds);
            return formatter.format(calendar.getTime());
        }
    }
    

    You can also check this

    Getting events from calendar

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

Sidebar

Related Questions

not able to get this, can someone help for this LINQ query? select col1,
I'm able to get the following results with this working query: $query = SELECT
I am able to get the current date, but I don't know how to
I am able to get the output of a pdf using fpdf, the problem
I'm not able to get this persistence file correct... I do not find any
When using win32api.setConsoleCtrlHandler() , I'm able to receive shutdown/logoff/etc events from Windows, and cleanly
I am generating events on fullCalendar with this code <script type=text/javascript> $(document).ready(function() { $('#calendar').fullCalendar({
I'm building a dynamic code generator and using regular expressions. Given this block of
I am not able to get the hg head or status for a given
I am able to get the current page's url in jsf from back-end bean

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.