I am storing things in a sqlite database. One of its attributes is a color. When I display this, I want to do
objLinearLayout.setBackgroundColor(some_int)
Normally I'd use R.color.red in place of some_int. However, I am persisting the color, and I think the R file generates a new id for red each time I run the app, making that method not feasible. I could store the string representation, like "red", and in my java code check for the color string and apply the correct R.color, but that looks ugly. Is there a way around that?
You could store hex codes and use it when you set colors.
Like ll.setBackgroundColor(Color.parseColor("#ffffff"));
Here's some good explanation on the comments of another question.
Changing Color with LinearLayout and TextView in Java (Android)