0

I'm getting a Sort order is not supported error when trying to apply a sort order to my query. The query runs just fine if the sort order is null. Can anyone help me here? Code is below:

            long currentTime = System.currentTimeMillis();
            Uri.Builder builder = WearableCalendarContract.Instances.CONTENT_URI.buildUpon();
            ContentUris.appendId(builder, currentTime);
            ContentUris.appendId(builder, currentTime + DateUtils.DAY_IN_MILLIS);

            final String[] PROJECTION = {
                    CalendarContract.Calendars._ID, // 0
                    CalendarContract.Instances.BEGIN, // 1
                    CalendarContract.Instances.END, // 2
                    CalendarContract.Events.DISPLAY_COLOR, // 3
                    CalendarContract.Events.TITLE, // 4
                    CalendarContract.Events.ALL_DAY // 5
            };

            final Cursor cursor = getContentResolver()
                    .query(builder.build(),
                            PROJECTION,
                            null, // selection (all)
                            null, // selection args
                            CalendarContract.Instances.BEGIN + " ASC"); // order
rjr-apps
  • 352
  • 4
  • 13
  • The error seems pretty self explanatory - what exactly do you need help with? – ianhanniballake Jun 07 '16 at 02:42
  • Nothing I have tried as a sort order works. Additionally when searching for solutions to this, every example I found of working queries had the same thing or similar as their sort order. I feel like something else must be wrong here; or that perhaps querying WearableCalendarContract works differently somehow, since all the examples I found were actually just looking at CalendarContract. Documentation was unhelpful here, unfortunately. – rjr-apps Jun 07 '16 at 02:50

1 Answers1

1

Exactly as the error message says, WearableCalendarContract.Instances.CONTENT_URI does not support sorting. It is a completely separate implementation from CalendarContract, even though it shares the same fields.

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
  • Ahh, I get it now. I was assuming the error meant that I had the wrong thing in the sort order - it hadn't occurred to me that it was trying to tell me sort orders aren't supported at all. Thanks! – rjr-apps Jun 07 '16 at 03:24