Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 818
Ömer Birler Avatar asked Aug 08 '17 16:08

Ömer Birler


People also ask

What is SAF storage?

Android 4.4 (API level 19) introduces the Storage Access Framework (SAF). The SAF enables users to browse and open documents, images, and other files across all their preferred document storage providers. A standard UI lets users browse files and access them in a consistent way across apps and providers.


1 Answers

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.

like image 158
CommonsWare Avatar answered Oct 03 '22 21:10

CommonsWare