public class

DocumentSharingProvider

extends BaseFileProvider
java.lang.Object
   ↳ android.content.ContentProvider
     ↳ com.pspdfkit.framework.utilities.BaseFileProvider
       ↳ com.pspdfkit.document.sharing.DocumentSharingProvider

Class Overview

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" />
 
 

Summary

[Expand]
Inherited Constants
From interface android.content.ComponentCallbacks2
Public Constructors
DocumentSharingProvider()
Public Methods
static void checkProviderConfiguration(Context context)
Tests if DocumentSharingProvider is configured correctly in AndroidManifest.xml.
static Uri createTemporaryFile(Context context, String fileName, String fileExtension)
Creates temporary file and returns its Uri.
static boolean deleteFile(Context context, Uri sharedFileUri)
Deletes file handled by this provider.
static String getDocumentProviderAuthority(Context context)
Returns authority for this DocumentSharingProvider.
static File getSharedFileDirectory(Context context)
Returns directory from which DocumentSharingProvider can share files.
static File getTempFileDirectory(Context context)
Returns directory from which DocumentSharingProvider can share temporary files.
static Uri getUriForFile(Context context, File fileName)
Return a content URI for a file stored in getSharedFileDirectory(Context) directory.
[Expand]
Inherited Methods
From class com.pspdfkit.framework.utilities.BaseFileProvider
From class android.content.ContentProvider
From class java.lang.Object
From interface android.content.ComponentCallbacks
From interface android.content.ComponentCallbacks2

Public Constructors

public DocumentSharingProvider ()

Public Methods

public static void checkProviderConfiguration (Context context)

Tests if DocumentSharingProvider is configured correctly in AndroidManifest.xml.

Parameters
context Context of the calling component, used for accessing files.
Throws
PSPDFKitException when provider is not configured correctly.

public static Uri createTemporaryFile (Context context, String fileName, 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.

public static boolean deleteFile (Context context, 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.

public static String getDocumentProviderAuthority (Context context)

Returns authority for this DocumentSharingProvider.

Parameters
context Context of the calling component, used for accessing files.

public static File getSharedFileDirectory (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.
Throws
IllegalStateException If directory couldn't be created.

public static File getTempFileDirectory (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.
Throws
IllegalStateException If directory couldn't be created.

public static Uri getUriForFile (Context context, File fileName)

Return a content URI for a file stored in getSharedFileDirectory(Context) 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.