简体   繁体   English

在Gallery Android中打开特定的文件夹

[英]Open a specific folder inside gallery android

I have a camera app which save image to separate folder inside the gallery. 我有一个相机应用程序,可以将图像保存到图库内的单独文件夹中。 Path to my folder is /storage/emulated/0/Pictures/CameraExample/ 我的文件夹的路径是/storage/emulated/0/Pictures/CameraExample/

When I click on the button I need to open the folder where I have saved the images. 当我单击按钮时,我需要打开保存图像的文件夹。 I have used all the solution which was available. 我已经使用了所有可用的解决方案。

This how I'm reading the path. 这就是我阅读路径的方式。 Let me know if i'm wrong. 让我知道我是否错。

String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath();
        Log.d("HelperUtils . getFilePaths", "setting the path " + path);
        String targetPath = path +"/CameraExample/";

How to start a new Intent and open the files? 如何启动新的Intent并打开文件?

You can list all files which exist in your directory like this 您可以像这样列出目录中存在的所有文件

File[] listFile;
File file = new File(android.os.Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "CameraExample");
if (file.isDirectory()) 
        listFile = file.listFiles();

Then you can display those images using GridView or however you want. 然后,您可以使用GridView或根据需要显示这些图像。

EDIT: To open your folder using intent 编辑:使用意图打开文件夹

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath()
+ "/CameraExample/");
intent.setDataAndType(uri, "*/*");
startActivity(Intent.createChooser(intent, "Open folder"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM