Get all files in raw folder in android -


lets have 100 .mp3 files in raw folder

for single known file can read files can use getresources().openrawresource(r.raw.myfilename)

but want files names in raw folder , pick random 1 list

any help?

public void listraw(){     field[] fields=r.raw.class.getfields();     for(int count=0; count < fields.length; count++){         log.i("raw asset: ", fields[count].getname());     } } 

since actual files aren't sitting on filesystem once they're on phone, name irrelevant, , you'll need refer them integer assigned resource name. in above example, integer thus:

int resourceid=fields[count].getint(fields[count]); 

this same int you'd referring r.raw.whateveryounamedtheresource

refer


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -