How to reference media files by using string array in android? -
in android program, have string array containing words, eg:
string arr[]={"asong", "bsong", "csong"};
i have media files same name in res/raw folder. array size large(50-60 elements). want play raw files using
r.raw.(arr[1])
or may equal r.raw.bsong, there way this? or have reference each 1 separately tradition?
string arr[]={"asong", "bsong", "csong"}; (int = 0; < arr.length; i++) { int song= getresources().getidentifier("raw/" + arr[i], null, getpackagename()); inputstream inputstream = getresources().openrawresource(song); // play song logic here }
Comments
Post a Comment