So you want to iterate over a group of strings? Why not use simple rows with indexes?
<string name="string_deftype">string</string> <string name="mylexicon_identifier">level_%1$d_group_%2$d_word_%3$d</string> <string name="level_1_group_1_word_1">the</string> <string name="level_1_group_1_word_2">the little boy</string> .... <string name="level_2_group_2_word_1">i</string> <string name="level_2_group_2_word_2">i can go</string>
And then in your activity or context
this.getResources().getIdentifier(getString(R.string.mylexicon_identifier, index_level, index_group, index_word), getString(R.string.string_deftype), getApplicationContext().getPackageName()));
So what you can basically do with this:
loop levels loop groups loop words
If you need to check your cycles, if there is an appropriate resource (look in the documentation)
getIdentifier() != 0
Keep in mind that this approach is not very fast, as indicated in the documentation. Hope this helps.
PS: You can also use the database, of course. ^^
source share