getResources().getColor() is deprecated

As we already know getResources().getColor() is deprecated since API level 23 from the official document

So what is the alternative of getColor()?

from API level 23, getColor is added in ContextCompat.

So just call

from official document of ContextCompat.getColor()

Returns a color associated with a particular resource ID

Starting in M, the returned color will be styled for the specified Context’s theme.

Android DataBinding With Fragment
Disable future dates from DatePickerDialog in Android