In my code res.getDrawable(R.drawable.image_name) is deprecated. I have done some research and found this ContextCompat.getDrawable(getActivity(), R.drawable.name);
I have tried it but it is not working. Android Studio says "Cannot solve the method getActivity()" i tried to change getActivity() with this but i have an error that says "....ShoppingCartHelper Cannot be referenced from a static context"
This is my code:
public class ShoppingCartHelper {
    public static final String PRODUCT_INDEX = "PRODUCT_INDEX";
    private static List<Product> catalog;
    private static List<Product> cart;
    public static List<Product> getCatalog(Resources res){
        if(catalog == null) {
            catalog = new Vector<Product>();
            catalog.add(new Product("Dead or Alive", res.getDrawable(R.drawable.blucaffe),
                    "Dead or Alive by Tom Clancy with Grant Blackwood", 29.99));
            catalog.add(new Product("Switch", res
                    .getDrawable(R.drawable.arabic),
                    "Switch by Chip Heath and Dan Heath", 24.99));
            catalog.add(new Product("Watchmen", res
                    .getDrawable(R.drawable.espressobar),
                    "Watchmen by Alan Moore and Dave Gibbons", 14.99));
        }
        return catalog;
    }
    public static List<Product> getCart() {
        if(cart == null) {
            cart = new Vector<Product>();
        }
        return cart;
    }
}
I don't understand why it is not working. I have tried many other code snippets but it is always giving me errors.
