I am working on an Android gallery activity where all the images come from a directory specific to that application. I would like all the images in the directory to be loaded in a manner similar to this.
public Integer[] mThumbIds = {
R.drawable.ic_launcher_background,R.drawable.ic_launcher_foreground
};
The images are getting saved to an internal directory and I would like to display them as a gallery. How do I get them into the data structure above if they are located here?
File directory = new File("/data/data/com.boredgiant.chora/files"); //path is the string specifying your directory path.
File[] files = directory.listFiles();
CodePudding user response:
The integers you use are resource identifiers.
You get a File array for your path.
A File instance or a String for a path can not be converted to an interger. And even if you could the integer would be interpreted as resource identifier and your files are not resources.
But no need for an integer.
You can display files very easy using a file path or a File class instance.
Adapt your adapter. Use File array instead of Integer array.
Little work ;-)