If i defined a color in resources
#123456
it\'s possible
The answers provided above are not updated.
Please try this one
String colorHex = "#" + Integer.toHexString(ContextCompat.getColor(getActivity(), R.color.dark_sky_blue) & 0x00ffffff);