<string id="I want To Get This">and this</string>
<string id="I want To Get This">and this</string>
<string id="I want To Get This">and this</string>
How to get the value
<string id="I want To Get This">and this</string>
<string id="I want To Get This">and this</string>
<string id="I want To Get This">and this</string>
How to get the value
To get the value from String Resource you use
String stringToCompare= getString(R.string.my_custom_id);
After that you can add that value to a list
myList.add(value)
Now if you say all similar I suppose you mean equal values or at least same characters. For that you could iterate over all the string values via reflection
for (Field field : R.string.class.getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers()) && !Modifier.isPrivate(field.getModifiers()) && field.getType().equals(int.class)) {
try {
if (field.getName().toLoweCase().equals(stringToCompare.toLowerCase())) {
int id = field.getInt(null);
myList.add(getString(id))
}
} catch (IllegalArgumentException e) {
// ignore
} catch (IllegalAccessException e) {
// ignore
}
}
}
Or can find another way of doing that iteration here How to easily iterate over all strings within the "strings.xml" resource file?