use Resources.getResourcesName(int)
,
Return the full name for a given resource identifier
here you can find the documentation. You can also use reflection:
private ArrayList<String> getKeysName(Context context, String className) {
Class c;
ArrayList<String> fieldsName = new ArrayList<String>();
try {
c = Class.forName(context.getPackageName() + ".R$" + className);
Field[] fields = c.getDeclaredFields();
for (Field f : fields) {
Log.e("LOG_TAG", " " + f.getName());
fieldsName.add(f.getName());
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return fieldsName;
}
and call it like getKeysName(context, "string");
, to get, for instance all the keys declared inside string.xml.