Use the getColor(Resources, int, Theme)
method of the ResourcesCompat
from the Android Support Library.
int white = ResourcesCompat.getColor(getResources(), R.color.white, null);
I think it reflect better your question than the getColor(Context, int)
of the ContextCompat
since you ask about Resources
. Prior to API level 23, the theme will not be applied and the method calls through to getColor(int)
but you'll not have the deprecated warning. The theme also may be null
.