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
Comments
Post a Comment