I am accessing default location of sdcard where images are stored after capturing. I am doing so in background service. But as soon as camera is opened, exception is being thrown called ConcurrentModificationException()
String absPath = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DCIM).toString()+"/100MEDIA/";
File folder = new File(absPath);
File[] listOfFiles = folder.listFiles();
for (int j = 0; j < listOfFiles.length; j++) {
if (listOfFiles[j].isFile()) {
temp.add(listOfFiles[j].getName());
}
}
This is my code in which I am creating list of images in dcim folde. What is causing exception and how to solve it?
temp
list on this worker thread, my guess is you're doing something else withtemp
on main thread.