本文介绍了在Gallery Android中打开特定的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相机应用程序,可以将图像保存到图库中的单独文件夹中.我的文件夹的路径是/storage/emulated/0/Pictures/CameraExample/

I have a camera app which save image to separate folder inside the gallery.Path to my folder is /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/";

如何启动新的Intent并打开文件?

How to start a new Intent and open the files?

推荐答案

您可以像这样列出目录中存在的所有文件

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();

然后,您可以使用GridView或根据需要显示这些图像.

Then you can display those images using GridView or however you want.

使用意图打开文件夹

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"));

这篇关于在Gallery Android中打开特定的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 22:12