My Application Has 2 types of provider
- DocumentProvider ( DP )is exported="true" required by the specs
- ContentProvider (CP)is exported="false" required by the security
Basic communication flow is 3rd Application asks DP for some info and DP ask CP for this info and return info to 3rd application.
Lets assume we use Microsoft Word/Excel to fetch some data from DocumentProvider. This is the scheme of the flow of communication between applications:
Word < ------- > Document Provider < ---- error here ---- > ContentProvider
The issue is that DocumentProvider doesn't have access to its own ContentProvider. I mean that DP and CP are inside 1 application but they run in different processes.
The error is:
java.lang.SecurityException: Permission Denial: reading com.app.name.provider.DataBaseContentProvider uri content://com.app.name.db.provider/files/innnerFiles/151515 from pid=6655, uid=10042 requires the provider be exported, or grantUriPermission
DP:
<provider
android:name="com.app.name.provider.DocProvider"
android:authorities="com.app.name.provider.DocProvider"
android:exported="true"
android:grantUriPermissions="true"
android:permission="android.permission.MANAGE_DOCUMENTS">
<intent-filter>
<action android:name="android.content.action.DOCUMENTS_PROVIDER" />
</intent-filter>
</provider>
CP:
<provider
android:name="com.app.name.provider.DBProvider"
android:authorities="com.app.name.provider.DBProvider"
android:exported="false" />
The attribute
attribute, which is your package name in this example,
the type of content provider (documents)
Custom document provider