AnonProg
AnonProg

Reputation: 117

Android opening file with intent doesn't show files

I am trying to have my app open a file selector with the following code:

Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.setType("file/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(intent, SELECT_FILE);

However, this only opens up a screen asking me to select a file from Recents, Google Drive, or my Downloads. I have tried variations of ACTION_OPEN_DOCUMENT, ACTION_GET_CONTENT, and ACTION_PICK. They all take me to the same screen.

How do I fix it so that it will open up a file selector where I can browse the files on my phone?

Upvotes: 0

Views: 283

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006539

I am trying to have my app open a file selector with the following code

There is no MIME type that begins with file/, according to the people who maintain the roster of valid MIME types. Use */*.

How do I fix it so that it will open up a file selector where I can browse the files on my phone?

Use the code that you have.

The screen that you cite will look something like this:

Documents UI

In the overflow, there will be an option named "Show internal storage" (or something like that). Click that, and you will be given an option to browse what the Android SDK calls external storage.

Upvotes: 1

Related Questions