How to make FileProvider available for other applications?

Is it possible to have FileProvider for other applications?

manifest.xml

... <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.example.myapp.fileprovider" android:exported="true" android:grantUriPermissions="false" android:permission="com.example.filesvisible.permission.READ" > <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/filespath" /> </provider> ... 

From doc :

false: provider is not available for other applications. Set android: exported = "false" to restrict access to the application provider. Only applications that have the same user ID (UID) as the provider will access it.

I tried to set the exported to true, but I got this Unable to get provider android.support.v4.content.FileProvider: java.lang.SecurityException: Provider must not be exported exception Unable to get provider android.support.v4.content.FileProvider: java.lang.SecurityException: Provider must not be exported Why can't I export FileProvider?

+7
android android-contentresolver android-fileprovider provider
source share
1 answer

Is it possible to have FileProvider for other applications?

Yes. This is usually the point.

Why can't I export FileProvider?

Because you are not using FileProvider .

The point behind FileProvider is to provide file access to third-party applications . You can do this with FLAG_GRANT_READ_URI_PERMISSION and / or FLAG_GRANT_WRITE_URI_PERMISSION in Intent , which you use to pass one of your Uri providers to a third-party application (for example, through ACTION_VIEW Intent used with startActivity() ).

Also see the file sharing guide .

+14
source share

All Articles