getcolor deprecated

Java
ContextCompat.getColor(context, R.color.color_name)
Source

Also in Java: