View images from folder in android
This is the sample code for view all the image from the particular folder from sdcard or from your device storage.
Simple step to do this:
1)First,set the file location in 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)); |
No comments:
Post a Comment