I know that's an old question, but it might help more people. What you can do is to call getIdentifier(), like our friends said. For that, you'll need to call it inside a loop, inserting after what value you want for a this variable, to make the string that you want for your resource ID. For exemple:
Your resources file:
R.string.string0
R.string.string1
R.string.string2
...
R.string.string9
In java:
for (i=0;i<10;i++){
int resourceId = getResources().getIdentifier("string"+i, "string", this.getPackageName())
println(getResources().getString(resourceId));
}
Then, in your rescourceId variable, you'll have an equivalent to: R.string.string0 to R.string.string9. And, in println, you'll have the value correspondent of your resources string.
In Kotlin:
for (i in 0..10){
val resourceId = this.resources.getIdentifier("string"+i, "string", this.packageName)
println(resources.getString(resourceId))
}
With the same explanation that I said before.