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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -