1.
Starting from Android Support Library 23, a new getColor() method has been added to ContextCompat.
So, just call:
ContextCompat.getColor(context, R.color.your_color);
This is the ContextCompat.getColor() source code from the Support Library:
public static final int getColor(Context context, int id) {
final int version = Build.VERSION.SDK_INT;
if (version >= 23) {
return ContextCompatApi23.getColor(context, id);
} else {
return context.getResources().getColor(id);
}
}