Why app stops when i use "Long.parseLong(uri.getLastPathSegment());"

This works:

 void strt(){
    Calendar beginTime = Calendar.getInstance();
    beginTime.set(2018, 2, 14, 7, 30);
    Calendar endTime = Calendar.getInstance();
    endTime.set(2018, 2, 15, 8, 30);

    Intent intent = new Intent(Intent.ACTION_INSERT)
            .setData(CalendarContract.Events.CONTENT_URI)
            .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, beginTime.getTimeInMillis())
            .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getTimeInMillis())
            .putExtra(CalendarContract.Events.TITLE, "Yoga")
            .putExtra(CalendarContract.Events.DESCRIPTION, "Group class")
            .putExtra(CalendarContract.Events.EVENT_LOCATION, "The gym")
            .putExtra(CalendarContract.Events.AVAILABILITY, CalendarContract.Events.AVAILABILITY_BUSY)
            .putExtra(Intent.EXTRA_EMAIL, "rowan@example.com,trevor@example.com");
   Uri uri = CalendarContract.Events.CONTENT_URI;
   //`long eventID = Long.parseLong(uri.getLastPathSegment());`

but when i add that line

long eventID = Long.parseLong(uri.getLastPathSegment());

app stops P.S. I'm trying to get eventID for reminder