Search code examples
javaandroidandroid-studiocalendar

Setting Event in CalendarView in Android Studio


I am making an Exercise app that is designed so the user uses it once per day. Say the current date is July 9, 2016... How would I go about setting the first event on the current date(July 9) and the second event on July (11) and so forth.


Solution

  • You can access dates using the Calendar class. to get the current date/time you can just do the following

    Calendar cal = Calendar.getInstance();
    

    if you wanted to get a different day you can do something like

    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.DAY_OF_MONTH, 11);