Ömer Birler
Ömer Birler

Reputation: 160

How to set uncommon file extension in storage access framework?

I am developing an android application that creates and opens specific file types. I am using Storage Access Framework to access files for Kitkat or above operating system. Now I need to open .enc files and filter out any other files. Using Storage Access Framework I tried:

Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("file/enc");

and

Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType(".enc");

but none of them working. Help me please.

Upvotes: 7

Views: 1397

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006944

Now I need to open .enc files and filter out any other files

That is not possible, sorry.

Besides, there is nothing stopping the user or other software from having a perfectly valid file that just happens to not have .enc as the file extension, because perhaps the content is not represented as a file. For example, this Web page is in HTML but the URL does not end in .html.

Instead, allow the user to pick anything, then validate the resulting selection to see if it seems to be well-constructed for whatever file format you are expecting.

Upvotes: 3

Related Questions