View images from folder in android

View images from folder in android

This is the sample code for view all the image from the particular folder from sd card or from your device storage.

1. First, set the file location in the file.

File file= new File(android.os.Environment.getExternalStorageDirectory().
getAbsolutePath(),"Images");
2. get all the file available in the location.
listFile = file.listFiles();

3. Add all the available file into the ArrayList.

for
(int
i = 0; i < listFile.length;
i++)
{
f.add(listFile[i].getAbsolutePath());
}

4. Finally,add all the files into the listview.

galleryListview.setAdapter(new img_adapter(context,f));

Screenshot

View images from folder in android
View images from folder in android

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to Top