Class DocumentSharingProvider
-
- All Implemented Interfaces:
-
android.content.ComponentCallbacks
,android.content.ComponentCallbacks2
public class DocumentSharingProvider extends BaseFileProvider
Provider allowing access to shared files. To use this provider you just need to add this to your
AndroidManifest.xml
:<provider android:name="com.pspdfkit.document.sharing.DocumentSharingProvider" android:authorities="[your application package name].pdf.share" android:exported="true" android:grantUriPermissions="true" />
-
-
Constructor Summary
Constructors Constructor Description DocumentSharingProvider()
-
Method Summary
Modifier and Type Method Description static Uri
getUriForFile(@NonNull() Context context, @NonNull() File fileName)
Return a content URI for a file stored in getSharedFileDirectory directory. static void
checkProviderConfiguration(@NonNull() Context context)
Tests if DocumentSharingProvider is configured correctly in AndroidManifest.xml
.static void
checkProviderConfiguration(@NonNull() Context context, @NonNull() String featureName)
Tests if DocumentSharingProvider is configured correctly in AndroidManifest.xml
.static String
getDocumentProviderAuthority(@NonNull() Context context)
Returns authority for this DocumentSharingProvider. static File
getSharedFileDirectory(@NonNull() Context context)
Returns directory from which DocumentSharingProvider can share files. static File
getTempFileDirectory(@NonNull() Context context)
Returns directory from which DocumentSharingProvider can share temporary files. static Uri
createTemporaryFile(@NonNull() Context context, @NonNull() String fileName, @Nullable() String fileExtension)
Creates temporary file and returns its Uri. static boolean
deleteFile(@NonNull() Context context, @NonNull() Uri sharedFileUri)
Deletes file handled by this provider. -
-
Method Detail
-
getUriForFile
@NonNull() static Uri getUriForFile(@NonNull() Context context, @NonNull() File fileName)
Return a content URI for a file stored in getSharedFileDirectory directory.
- Parameters:
context
- Context of the calling component, used for accessing files.fileName
- File name of the targeted file, must be part of the shared directory.
-
checkProviderConfiguration
static void checkProviderConfiguration(@NonNull() Context context)
Tests if DocumentSharingProvider is configured correctly in
AndroidManifest.xml
.- Parameters:
context
- Context of the calling component, used for accessing files.
-
checkProviderConfiguration
static void checkProviderConfiguration(@NonNull() Context context, @NonNull() String featureName)
Tests if DocumentSharingProvider is configured correctly in
AndroidManifest.xml
.- Parameters:
context
- Context of the calling component, used for accessing files.featureName
- Feature name to use in error messages.
-
getDocumentProviderAuthority
@NonNull() static String getDocumentProviderAuthority(@NonNull() Context context)
Returns authority for this DocumentSharingProvider.
- Parameters:
context
- Context of the calling component, used for accessing files.
-
getSharedFileDirectory
@NonNull() static File getSharedFileDirectory(@NonNull() Context context)
Returns directory from which DocumentSharingProvider can share files. Note that all files in this directory may be readable by other applications so make sure to not store any sensitive data there.
- Returns:
Path to shared directory inside applications getCacheDir directory.
-
getTempFileDirectory
@NonNull() static File getTempFileDirectory(@NonNull() Context context)
Returns directory from which DocumentSharingProvider can share temporary files. Note that all files in this directory may be readable by other applications so make sure to not store any sensitive data there.
- Returns:
Path to temporary directory inside applications getCacheDir directory.
-
createTemporaryFile
@Nullable() static Uri createTemporaryFile(@NonNull() Context context, @NonNull() String fileName, @Nullable() String fileExtension)
Creates temporary file and returns its Uri.
- Parameters:
context
- The context to use.fileName
- Name of the created temp file.fileExtension
- Optional extension of the created temp file.- Returns:
Uri to created temporary file. Returns null when temporary file could not be created.
-
deleteFile
static boolean deleteFile(@NonNull() Context context, @NonNull() Uri sharedFileUri)
Deletes file handled by this provider.
- Parameters:
context
- The context ot use.sharedFileUri
- Uri of file that should be removed.- Returns:
True if file was removed, false otherwise.
-
-
-
-