Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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/

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?

like image 382
Likith Ts Avatar asked Mar 04 '26 04:03

Likith Ts


1 Answers

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.

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"));
like image 154
Praveena Avatar answered Mar 05 '26 17:03

Praveena