Android get color as string value

Solution 1:

This is your answer

colorStr=getResources().getString(R.color.someColor);

you will get

 colorStr = "#123456"

Solution 2:

Just for the sake of easy copypasta:

"#" + Integer.toHexString(ContextCompat.getColor(getActivity(), R.color.some_color));

Or if you want it without the transparency:

"#" + Integer.toHexString(ContextCompat.getColor(getActivity(), R.color.some_color) & 0x00ffffff);