Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open default gallery app with particular album or folder?

Every example i found on net is opening gallery and get images from gallery as result. My need is i don't want result or images to my app. I just want to trigger gallery app with showing particular folder of images. My App Have separate folder to save images. i need to navigate users directly to that path.

like image 608
Rajaguru R Avatar asked Jan 21 '26 12:01

Rajaguru R


1 Answers

Try this code. It will retrieve view pictures under storage/emulated/0/Pictures/AppPics You can change the file path according to your directory path.

File sdDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File file = new File(sdDir, "AppPics");

if (file.isDirectory()) 
    listFile = file.listFiles();

EDIT: To open your folder using intent

Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.withAppendedPath(Uri.fromFile(file), "/AppPics"), "image/*");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
like image 190
akhilesh0707 Avatar answered Jan 24 '26 10:01

akhilesh0707