How to open a folder on android

Asked

Viewed 3,316 times

0

I wanted to open a directory on android, I tried so:

 public void openFolder()
    {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()
        + "/Pictures/");
    intent.setDataAndType(uri, "text/csv");
    startActivity(Intent.createChooser(intent, "Open folder"));
    }

But it’s time to call "impossible to find application to perform this action"

I just wanted to open the directory

  • Your goal is to select some file that your application will use?

  • my goal is to normally open the folder with all files, the application will not last.

  • The problem is that not everyone has a file manager installed. What happens if you change text/csv for */*?

  • appears to choose Contacts, photos, and gallery, but I want my folder

  • 2

    I believe that without a file manager installed you will not be able to open and browse the directory. Would it be feasible for you to create an Activity to list the contents of the directory? I think it would be your only option.

  • but I need to open, and delete the files, if that’s possible from right

Show 2 more comments

2 answers

1


1 - This folder exists?

2 - You have these permissions? <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

3 - You are using an AVD or Physical Device to run the application?

4 - In both of the above, whatever your response, there is a program like: Solid explorer, root explorer?

5 - This was supposed to work:

public void openFolder()
{
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()
    + "/Pictures/");
intent.setDataAndType(uri, "text/csv");
startActivity(Intent.createChooser(intent, "Abrindo pasta"));
}

A MIME LIKE "*/*" in place of "text/csv", would also solve.

  • This way it opens, to return to application with the file, and I do not want, I want to simply open the folder and forget the application

  • No way. Give it up! Check it out: http://stackoverflow.com/questions/17843962/view-folder-contents-in-android-using-default-explorer

  • i have to create my own manager? I just want to list the files to be able to open or delete. da para montar?

  • @Warlock, you want your application to HAVE ANOTHER application DO A CERTAIN TASK. This would only be possible if the other application was made only for what you want: Open a specific folder.

  • As things do not go as we planned, I advise you to review your project and see another alternative to this, example: list the files in your directory, in your own application.

  • OK, I need to list, open, and delete is possible?

  • yes. of course. you can.

  • which file???

  • all pdf of a directory, when I go to do I will create other topics

  • @Warlock, do you want to list read-only pdf files through an external application? You can only delete something if it is on the client’s device or make it "invisible" for viewing. How do you want to make these pdfs available? External server? Download? How you thought and WHAT YOU HAVE DONE?

Show 6 more comments

0

Come on, check this other way (see if it works).

public void abrirDiretorio()
          {
            File pasta = new File(Environment.getExternalStorageDirectory().getPath()
               + "/Pictures/");
            Uri local = Uri.fromFile(pasta);
            Intent intent = new Intent();
            intent.setAction(android.content.Intent.ACTION_VIEW);
            intent.setData(local);
            startActivityForResult(intent, 1);
          }
  • appears "document cannot be appended because it is not a valid pdf document"

  • I’ll clear the path to the bottom line.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.