3

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?

NoWar
  • 36,338
  • 80
  • 323
  • 498
Likith Ts
  • 296
  • 1
  • 7
  • 18
  • You did not tell how you open the Gallery app without indicating a specific folder. The gallery is no storage place as you suggest. It's only an app that can show all images on your device. – greenapps Jan 28 '15 at 15:40
  • possible duplicate of http://stackoverflow.com/questions/4019534/gallery-with-folder-filter – ShellDude Feb 14 '16 at 20:13

1 Answers1

4

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"));
Praveena
  • 6,340
  • 2
  • 40
  • 53
  • This is ok. But I need to open myfolder from built-in gallery. I don't want to create any gridview, bcoz android gallery handles everything. I just need to open myfolder. – Likith Ts Jan 28 '15 at 15:33
  • For that you need to create a MediaScanner, to let the gallery know what to show. The gallery will not show any images, even if they are in the same folder, unless they are explicitly added to the gallery. – G_V Jan 28 '15 at 15:41
  • Can you provide me a example on implementing MediaScanner. If is just implement MediaScanner , is that enough or should I have to do addition work in XML layout file. – Likith Ts Jan 28 '15 at 16:01
  • 3
    Above code is opening the recent images of gallery not the images from the specific folder. Example on implementing the media scanner? – Likith Ts Jan 28 '15 at 17:37
  • Cross check pictures in opend folder and cameraexample folder.. Should be same – Praveena Jan 29 '15 at 04:17