public class DocumentArchive extends Object implements Closeable
This class is thread safe.
Modifier and Type | Method and Description |
---|---|
void |
close()
Schedules a gracefully close of the archive after any opened files are closed.
|
static DocumentArchive |
createForLocalFile(Context context,
File file,
String documentId,
char idDelimiter,
Uri notificationUri)
Creates a DocumentsArchive instance for opening, browsing and accessing
documents within the archive passed as a local file.
|
static DocumentArchive |
createForParcelFileDescriptor(Context context,
ParcelFileDescriptor descriptor,
String documentId,
char idDelimiter,
Uri notificationUri)
Creates a DocumentsArchive instance for opening, browsing and accessing
documents within the archive passed as a file descriptor.
|
String |
getDocumentType(String documentId)
Returns a MIME type of a document within an archive.
|
boolean |
isChildDocument(String parentDocumentId,
String documentId)
Returns true if a document within an archive is a child or any descendant of the archive
document or another document within the archive.
|
ParcelFileDescriptor |
openDocument(String documentId,
String mode,
CancellationSignal signal)
Opens a file within an archive.
|
AssetFileDescriptor |
openDocumentThumbnail(String documentId,
Point sizeHint,
CancellationSignal signal)
Opens a thumbnail of a file within an archive.
|
Cursor |
queryChildDocuments(String documentId,
String[] projection,
String sortOrder)
Lists child documents of an archive or a directory within an
archive.
|
Cursor |
queryDocument(String documentId,
String[] projection)
Returns metadata of a document within an archive.
|
public static DocumentArchive createForLocalFile(Context context, File file, String documentId, char idDelimiter, @Nullable Uri notificationUri) throws IOException
context
- Context of the provider.File
- Local file containing the archive.documentId
- ID of the archive document.idDelimiter
- Delimiter for constructing IDs of documents within the archive.
The delimiter must never be used for IDs of other documents.Uri
- notificationUri Uri for notifying that the archive file has changed.IOException
createForParcelFileDescriptor(DocumentsProvider, ParcelFileDescriptor, String, char,
Uri)
public static DocumentArchive createForParcelFileDescriptor(Context context, ParcelFileDescriptor descriptor, String documentId, char idDelimiter, @Nullable Uri notificationUri) throws IOException
Note, that this method should be used only if the document does not exist
on the local storage. A snapshot file will be created, which may be slower
and consume significant resources, in contrast to using
createForLocalFile(Context, File, String, char, Uri
.
context
- Context of the provider.descriptor
- File descriptor for the archive's contents.documentId
- ID of the archive document.idDelimiter
- Delimiter for constructing IDs of documents within the archive.
The delimiter must never be used for IDs of other documents.Uri
- notificationUri Uri for notifying that the archive file has changed.IOException
createForLocalFile(Context, File, String, char, Uri)
public Cursor queryChildDocuments(String documentId, @Nullable String[] projection, @Nullable String sortOrder) throws FileNotFoundException
FileNotFoundException
DocumentsProvider.queryChildDocuments(String, String[], String)
public String getDocumentType(String documentId) throws FileNotFoundException
FileNotFoundException
DocumentsProvider.getDocumentType(String)
public boolean isChildDocument(String parentDocumentId, String documentId)
DocumentsProvider.isChildDocument(String, String)
public Cursor queryDocument(String documentId, @Nullable String[] projection) throws FileNotFoundException
FileNotFoundException
DocumentsProvider.queryDocument(String, String[])
public ParcelFileDescriptor openDocument(String documentId, String mode, @Nullable CancellationSignal signal) throws FileNotFoundException
FileNotFoundException
DocumentsProvider.openDocument(String, String, CancellationSignal))
public AssetFileDescriptor openDocumentThumbnail(String documentId, Point sizeHint, CancellationSignal signal) throws FileNotFoundException
FileNotFoundException
DocumentsProvider.openDocumentThumbnail(String, Point, CancellationSignal))
public void close()
This method does not block until shutdown. Once called, other methods should not be called.
close
in interface Closeable
close
in interface AutoCloseable