How can I get an int from a file?

AssetManager am = getApplicationContext().getAssets(); String[] files = am.list("my_images"); ArrayList<Drawable> drawables = new ArrayList<>(); for (String file : files) { showLog(file); Drawable d = Drawable.createFromStream(am.open("my_images/" + file), null); drawables.add(d); iconsList.add(тут нужно добавить значение int от drawable d); } 

Tried to do so, but did not help, always returns 0

 Resources resources = getApplicationContext().getResources(); final int resourceId = resources.getIdentifier(file, "drawable", getApplicationContext().getPackageName()); 

How correctly understood 0 because file is in asset/my_images how to get it?

So I tried too 0

 Resources resources = getApplicationContext().getResources(); final int resourceId = resources.getIdentifier(file, "asset/my_images", getApplicationContext().getPackageName()); 

    1 answer 1

    There is no identifier for files in the assets directory. Quote from the documentation :

    Access to source files

    In rare cases, you may need to access the source files and directories. In this case, simply saving the files in the res / directory will not be enough, since you can access the resource from the res / folder only by its identifier. Instead, you can save resources in the assets / directory.

    Files that are stored in the assets / directory are not assigned resource identifiers, so you will not be able to refer to them using the R class or from XML resources. Instead, you can request files from the assets / directory, as in a regular file system, and read the raw data using AssetManager.

    Accordingly, the getIdentifier method does not find such a resource and returns the default value, i.e. 0