How can I use Intent.ACTION_VIEW to view the contents of a folder?

30,104

Solution 1

I think this is far simpler than everyone else is suggesting. I believe the path is case sensitive. In your example "file://sdcard/Download" should work.

Solution 2

try something like this

Intent intent = new Intent();
intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 1);

or

Intent intent = new Intent();
intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 1);
Share:
30,104
Admin
Author by

Admin

Updated on December 19, 2020

Comments

  • Admin
    Admin over 3 years

    I'm trying to view the images in a specific folder using an intent. My code is as follows:

    Intent intent = new Intent();  
    intent.setAction(Intent.ACTION_VIEW);  
    Uri imgUri = Uri.parse("file://sdcard/download");  
    intent.setDataAndType(imgUri, "image/*");  
    startActivity(intent);  
    

    However, each time it runs, I get this message in the log:

    02-25 00:40:16.271: ERROR/(8359): can't open '/download'
    02-25 00:40:16.271: ERROR/(8359): can't open '/download'

    What am I doing wrong?