Search code examples
androidandroid-layoutandroid-intentandroid-emulator

How to get count of images stored in SD card


I need to calculate the number of images stored in SD card and so i would like to name the images unique like Sample0,Sample1,Sample2,Sample3,etc. Is it Possible?


Solution

  • It gives the number of images present in the images folder of your SD card:

    File dir = new File(Environment.getExternalStorageDirectory()
                    + "/images");
            File[] files = dir.listFiles();
            int numberOfImages=files.length;