简体   繁体   English

打开Android默认库中特定文件夹中的所有图像

[英]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.

相关问题 在 Android Studio 的 Gallery 中打开特定文件夹(不是图像) - Open a specific folder (not a image) in Gallery in Android Studio 无法打开具有特定文件夹链接的Android打开默认图库 - Android open default gallery with specific folder link cannot be loaded Android 从文件夹中打开图库 - Android open gallery from folder Android-在默认库应用程序中从可绘制对象打开图像 - Android - open image from drawable in default gallery application 在Gallery Android中打开特定的文件夹 - Open a specific folder inside gallery android 具有内置图库的Android打开文件夹图像 - Android open folder image with built-in gallery 如何打开Android照片库中的特定图像? - how to open a specific image in the android photo gallery ? cordova-plugin-camera:如何在特定文件夹中打开图像而不是显示图库中的所有图像 - cordova-plugin-camera : how to open images in specific folder instead of showing all images from gallery 如何为 Android Q 打开带有特定相册或文件夹的默认图库应用程序? - How to open default gallery app with particular album or folder for Android Q? 来自assest文件夹的Android画廊设置图像 - Android gallery setting image from assest folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM