android raw resource
is t开发者_StackOverflowhere any way to get the file names stored in the res/raw folder programmatically?
Why do you need that? Usually that's not a good idea and indicates that you have to work on your apps design. Probably you'd better store your images at /assets
folder or have an additional xml listing all of them. Anyhow here is an example how you can do that foe res/drawables
folder. So implementing that for res/raw
is as simple as:
Field[] raw = R.raw.class.getFields();
for (Field r : raw) {
try {
System.out.println("R.raw." + r.getName());
} catch (Exception e) {
e.printStackTrace();
}
}
精彩评论