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

  • Home
  • SEARCH
  • 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 7022663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:36:41+00:00 2026-05-27T23:36:41+00:00

I am having trouble in finding a solution to my problem. I am trying

  • 0

I am having trouble in finding a solution to my problem. I am trying to add multiple events into my Android calendar but I do not know how. I gave found this code :

        Calendar cal = Calendar.getInstance();              
            Intent intent = new Intent(Intent.ACTION_EDIT);
            intent.setType("vnd.android.cursor.item/event");
            intent.putExtra("beginTime", cal.getTimeInMillis());
            intent.putExtra("allDay", true);
            intent.putExtra("rrule", "FREQ=YEARLY");
            intent.putExtra("endTime", cal.getTimeInMillis()+60*60*1000);
            intent.putExtra("title", "A Test Event from android app"+String.valueOf(i));
            startActivity(intent);

but all it does is to send me to my calendar and lets me edit and manually insert my event. I want to insert the events automatically, without going to my calendar app. Moreover, I can add only one event using this code. This is not what I wanted.
I have 2 String arrays, one containing the date, and one containing the name of the event.
Does anyone know if there is a way to do this? I have been searching for a solution for quite a while and hadn’t found one. I would be grateful if anyone helped me. Thank you!

I have solved the problem! Thank you very much! But now I have another issue that I can’t solve.
I have this code :

        ContentValues cv = new ContentValues();
        cv.put("calendar_id", calIds[0]);
        cv.put("title", title);
        //cv.put("dtstart", dtstart );
        //cv.put("dtend", dtend);
        cv.put("rrule", "FREQ=MONTHLY");
        cv.put("description", comment );
        Calendar start = Calendar.getInstance();
        start.set(2012, 0, 2, 8, 0, 0);

        Calendar end = Calendar.getInstance();
        end.set(2012, 0, 2, 9, 0, 0);

        long startTime = start.getTimeInMillis();       
        long endTime = end.getTimeInMillis();

        cv.put("dtstart", startTime);
        cv.put("dtend", endTime);
        //Insertion on the events of the calendar
        cr.insert(Uri.parse("content://com.android.calendar/events"), cv);

It inserts my event but it doesn’t do it recurring. I mean that my event appears on 2jan2012 but on 2jan2013 doesn’t and neither does in 2014 and so on. So I opened my calendar on the phone and tried to edit my event and I saw that where I should select the occurence of it, there it shows on 2 january 2012 not on 2 january as it should if it were to customize my event from my phone. On the other hand, if I try to add an event manually from my phone it works just fine( I mean I can add an event that occurs yearly).

  • 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-27T23:36:41+00:00Added an answer on May 27, 2026 at 11:36 pm

    android SDK does not expose any interfaces to manipulate calendar, but you can find that from android source code. Android stores calendar in an internal sqlite database, though it’s protected from direct access but you can still add/delete/update/query calendar data through ContentResolver. A piece of code to insert an event could be like this:

    public String addEvent(String calendarId, String title, long startTime,
            long endTime, int allDay) {
        ContentValues event = new ContentValues();
        event.put("calendar_id", calendarId); // "" for insert
        event.put("title", title);
        event.put("description", "");
        event.put("eventLocation", "");
        event.put("allDay", allDay);
        event.put("eventStatus", 1);
        event.put("transparency", 0);
        event.put("dtstart", startTime);
        event.put("dtend", endTime);
    
        ContentResolver contentResolver = this.context.getContentResolver();
        Uri eventsUri = Uri.parse("content://com.android.calendar/calendars");
        Uri url = contentResolver.insert(eventsUri, event);
        String ret = url.toString();
        return ret;
    }
    

    When you insert one event successfully, a string represent uri of the event is returned by ContentResolver.insert, you can query, update or delete it later. In earlier SDKs before SDK 8, the content uri of calendar is “content://calendar/calendars” which differs from SDks 8 and after.

    Meanwhile, be careful with those custom roms. since calendar API is not noted in SDK docs, the calendar provider could be modified or even removed by some vendors and operators, so you may have to test your application against lots of devices.
    Good luck!

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

Sidebar

Related Questions

Ok, This seems straight forward but I am having trouble finding the solution. I
I'm having trouble finding a solution to this via google but I would have
I just caused a problem that I'm having trouble finding a solution for. I
I think this is a pretty simple question but I'm having trouble finding the
I'm a newbie to Silverlight and I'm having some trouble finding a solution to
I'm having trouble finding the right solution for this fully fluid layout. I want
Having trouble finding a solution for my situation here. Sorry if this has been
I'm having trouble right now finding a solution for unlocking UNC path files for
I'm trying to setup CruiseControl.NET for CI. I am having trouble finding references and
I am having some trouble finding a solution for a system of equations using

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.