is there any way to get the file names stored in the res/raw folder programmatically?
            Asked
            
        
        
            Active
            
        
            Viewed 1,735 times
        
    1 Answers
3
            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();
    }
}
 
    
    
        Community
        
- 1
- 1
 
    
    
        Konstantin Burov
        
- 68,980
- 16
- 115
- 93
 
    