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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:51:20+00:00 2026-06-02T21:51:20+00:00

I want to add a new calendar to Android that does not get synchronized.

  • 0

I want to add a new calendar to Android that does not get synchronized. I have written an App that does this using the new CalendarContract API from API level 14. The following code works fine. I can see the new calendar in Android’s calendar app and add events to it.

The problem is that the Android calendar app crashes when I select: Menu -> Calendars to display -> Calendars to sync

Is there something wrong in my code or is it a bug in Android calendar?

Mind that I do not want to actually use a sync adapter. The documentation of CalendarContract.Calendars says that this is not needed: “If a local calendar is required an app can do so by inserting as a sync adapter and using an ACCOUNT_TYPE of ACCOUNT_TYPE_LOCAL.” I understand that “inserting as a sync adapter” means to append (CalendarContract.CALLER_IS_SYNCADAPTER, “true”) to the URI.

public class CalendarMapper {

private static final String ACCOUNT_NAME = "private";
private static final String INT_NAME_PREFIX = "priv";

private static Uri buildCalUri() {
    return CalendarContract.Calendars.CONTENT_URI
            .buildUpon()
            .appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
            .appendQueryParameter(Calendars.ACCOUNT_NAME, ACCOUNT_NAME)
            .appendQueryParameter(Calendars.ACCOUNT_TYPE, CalendarContract.ACCOUNT_TYPE_LOCAL)
            .build();
}

private static ContentValues buildContentValues(Calendar calendar) {
    String dispName = calendar.getName();  //Calendar.getName() returns a String
    String intName = INT_NAME_PREFIX + dispName;
    final ContentValues cv = new ContentValues();
    cv.put(Calendars.ACCOUNT_NAME, ACCOUNT_NAME);
    cv.put(Calendars.ACCOUNT_TYPE, CalendarContract.ACCOUNT_TYPE_LOCAL);
    cv.put(Calendars.NAME, intName);
    cv.put(Calendars.CALENDAR_DISPLAY_NAME, dispName);
    cv.put(Calendars.CALENDAR_COLOR, calendar.getColor());  //Calendar.getColor() returns int
    cv.put(Calendars.CALENDAR_ACCESS_LEVEL, Calendars.CAL_ACCESS_OWNER);
    cv.put(Calendars.OWNER_ACCOUNT, ACCOUNT_NAME);
    cv.put(Calendars.VISIBLE, 1);
    cv.put(Calendars.SYNC_EVENTS, 1);
    return cv;
}

public static void addCalendar(Calendar calendar, ContentResolver cr) {
    if (calendar == null)
        throw new IllegalArgumentException();

    final ContentValues cv = buildContentValues(calendar);

    Uri calUri = buildCalUri();
    cr.insert(calUri, cv);
}

}

Here is the Stack Trace of the Exception that causes the calendar app to crash:

  03-22 07:12:39.437: E/AndroidRuntime(9730): FATAL EXCEPTION: main
  03-22 07:12:39.437: E/AndroidRuntime(9730): java.lang.NullPointerException
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at com.android.calendar.selectcalendars.SelectSyncedCalendarsMultiAccountAdapter.bindGroupView(SelectSyncedCalendarsMultiAccountAdapter.java:324)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.widget.CursorTreeAdapter.getGroupView(CursorTreeAdapter.java:207)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.widget.ExpandableListConnector.getView(ExpandableListConnector.java:445)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.widget.AbsListView.obtainView(AbsListView.java:2033)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.widget.ListView.makeAndAddView(ListView.java:1772)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.widget.ListView.fillDown(ListView.java:672)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.widget.ListView.fillFromTop(ListView.java:732)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.widget.ListView.layoutChildren(ListView.java:1611)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.widget.AbsListView.onLayout(AbsListView.java:1863)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.view.View.layout(View.java:11278)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.view.ViewGroup.layout(ViewGroup.java:4224)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.widget.LinearLayout.onLayout(LinearLayout.java:1399)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.view.View.layout(View.java:11278)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.view.ViewGroup.layout(ViewGroup.java:4224)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.view.View.layout(View.java:11278)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.view.ViewGroup.layout(ViewGroup.java:4224)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.widget.LinearLayout.onLayout(LinearLayout.java:1399)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.view.View.layout(View.java:11278)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.view.ViewGroup.layout(ViewGroup.java:4224)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.view.View.layout(View.java:11278)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.view.ViewGroup.layout(ViewGroup.java:4224)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1489)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.os.Handler.dispatchMessage(Handler.java:99)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.os.Looper.loop(Looper.java:137)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at android.app.ActivityThread.main(ActivityThread.java:4424)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at java.lang.reflect.Method.invokeNative(Native Method)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at java.lang.reflect.Method.invoke(Method.java:511) 
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
  03-22 07:12:39.437: E/AndroidRuntime(9730):   at dalvik.system.NativeStart.main(Native Method)
  • 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-02T21:51:22+00:00Added an answer on June 2, 2026 at 9:51 pm

    This is an Android bug and apparently will be fixed: http://code.google.com/p/android/issues/detail?id=27474

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

Sidebar

Related Questions

I have this code Calendar c = new GregorianCalendar(); c.add(Calendar.DAY_OF_YEAR, 1); c.set(Calendar.HOUR_OF_DAY, 23); c.set(Calendar.MINUTE,
I want add new fonts for Android. I found a tutorial that asks me
I want to add a new time-field to a an existing MySQL-table that is
I have master branch of the project. Then I want to add a new
I have a web-app that is a sort of calendar application and there are
I have this widget in android, that displays an image and gets updated periodically
I want to add calendar events in android 4.0 and above version device. Currently
I want to get calendar event last sevendays on android devices ? i am
What I want: I want to add calendar events in Android 2.2. What I
I am currently using VB. I want to do a Calendar Control which have

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.