问题
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?
回答1:
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"));
来源:https://stackoverflow.com/questions/28195788/open-a-specific-folder-inside-gallery-android