I do not understand why you need to repeat ALL lines, instead of calling the class when you need one specific line.
But as you asked ...
I think this may help you; -)
Field[] fields = R.string.class.getFields(); for(final Field field : fields) { String name = field.getName(); //name of string try{ int id = field.getInt(R.string.class); //id of string }catch (Exception ex) { //do smth } }
source share