Declare string array in res/values/strings.xml
.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="messages">
<item>Hello</item>
<item>Good day</item>
<item>Hi</item>
</string-array>
</resources>
Extract string array by code.
val messages = context.resources.getStringArray(R.array.messages)for (message in messages) {}
NOTE: If R.array
doesn't appear, make sure you are acessing the correct R
(<PACKAGE_NAME>.R)