here is the way, how to get all images in a known asset subfolder. Only thing you need to know is the name of the subfolder with images in asset. Hope it will help.
private List<Bitmap> imageListFromAsset(String dirFrom) {
//list of images in assets
List<Bitmap> imageList = new ArrayList<Bitmap>();
Resources res = getResources();
AssetManager am = res.getAssets();
String fileList[];
try {
fileList = am.list(dirFrom);
for (String fileName : fileList) {
imageList.add(getImageFromAsset(dirFrom+ File.separator +fileName, am));
}
} catch (IOException e) {
e.printStackTrace();
}
return imageList;
}
private Bitmap getImageFromAsset(String path, AssetManager assetManager) {
InputStream istr = null;
try {
istr = assetManager.open(path);
} catch (IOException e) {
e.printStackTrace();
}
Bitmap bitmap = BitmapFactory.decodeStream(istr);
return bitmap;
}
If you need only paths to these images just stop atfileList = am.list(dirFrom);
. Don't forget to add dirName before fileName.
EDIT as per request in comment:
Resources res = getResources();
AssetManager am = res.getAssets();
String fileList[];
try {
fileList = am.list(dirFrom);
for (String fileName : fileList) {
fileName = dirFrom + File.separator + fileName;
}
} catch (IOException e) {
e.printStackTrace();
}
Now you have all filePaths in assets/dirName. Now conversion to ArrayList;
List<String> imagePaths = new ArrayList<String>(Arrays.asList(fileList));
And now the image paths are in the list.