0

I have a list of mp3 files under my asset folder, I want to list the files and there paths that exist under this directory.

I have tried getAssets() but all what I get is filenames.

is there any other way?

thanks in advance

  • give a look to this question, that is very similar: http://stackoverflow.com/questions/9564950/android-list-files-contained-in-assets-subfolder – ZLNK Oct 14 '16 at 20:10
  • Possible duplicate of [How to determine the Absolute path for specific file from Assets?](http://stackoverflow.com/questions/4744169/how-to-determine-the-absolute-path-for-specific-file-from-assets) – Mike M. Oct 14 '16 at 20:11
  • 2
    "I have tried getAssets() but all what I get is filenames" -- um, what else are you expecting? – CommonsWare Oct 14 '16 at 20:13
  • I m trying to build a map with file names (as song title) and the corresponding file path. with getAsset() you get only filenames. – user3291059 Oct 15 '16 at 02:52

1 Answers1

0

This question was already answered here in the link below in stackoverflow:

android list files contained in assets subfolder

Then with their names you can access them depend on what they are e.g. If they are image you access them like below:

try {
InputStream im = getAssets().open("image.jpg");
Drawable d = Drawable.createFromStream(im, null);
imageView.setImageDrawable(d);
}
catch(IOException ex) {
return;
}
Community
  • 1
  • 1
Amir Ziarati
  • 14,248
  • 11
  • 47
  • 52
  • this not what I meant. Iw ant a file object usign getAsset or something else – user3291059 Oct 15 '16 at 02:49
  • three is not such a thing to get all files in asset. the asset folder list can provide you a string list of files then you can find the type of that with its extension and get that using `getAssets.open(assetName)`. thats all you can do. it will give you an inputStream by the name. – Amir Ziarati Oct 15 '16 at 06:16