Marcus Runge
Marcus Runge

Reputation: 635

Add custom mime type in Android with storage access framework

I want to allow to open only two file types with storage access Framework. 1. *.zip 2. *.ovpn (custom) The zip file is selectable but the ovpn file is not. How can I get this working? The Code below only works with zip files:

Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.putExtra("android.provider.extra.INITIAL_URI", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS));
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
String[] extraMimeTypes = {"application/zip", "application/ovpn"};
intent.putExtra(Intent.EXTRA_MIME_TYPES, extraMimeTypes);
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
startActivityForResult(intent, VPN_PROFILES_REQUEST_CODE);

Thanks for any assistance. Marcus

Upvotes: 0

Views: 980

Answers (1)

Marcus Runge
Marcus Runge

Reputation: 635

This is simply not possible. A Workaround is checking the Extension later

Upvotes: 1

Related Questions