[英]Open all image from specific folder in Android default gallery
My requirement is to open all images and video's of specific folder. 我的要求是打开特定文件夹的所有图像和视频。 I have refereed this link, Now I am able to show a image in gallery but I want to show all images from a specific folder.
我已经引用了此链接,现在我可以在图库中显示图像,但是我想显示特定文件夹中的所有图像。 Almost all link I have tried on stack but did not get success.
几乎所有我尝试过的链接都没有成功。
You can set path in File object initialize at that time. 您可以在当时的File对象初始化中设置路径。 File folder = new File("/sdcard/Photo/");
文件夹=新文件(“ / sdcard / Photo /”); in this tutorial default path is /sdcard/photo/ at this place you can set your path then get your files.
在本教程中,默认路径是/ sdcard / photo /在此位置,您可以设置路径然后获取文件。
I sinc it is not good idea but you may write your own searcher in all files on mobile phone for example 我认为这不是一个好主意,但是您可以在手机上的所有文件中编写自己的搜索器
public ArrayList<File> getAllphotos(String path){
ArrayList<File> photoPath = new ArrayList<>();
File yourDir = new File(path);
for (File f : yourDir.listFiles()) {
String mas[] = f.toString().split("\\.");
if(mas[mas.length - 1].equalsIgnoreCase("png") || mas[mas.length - 1].equalsIgnoreCase("jpeg")){//or other formats
//it is picture
photoPath.add(f);
}
}
return photoPath;
}
call this wis iternal and external storage 称之为内部和外部存储
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.