public class DocumentArchiveHelper extends Object implements Closeable
This class is thread safe. All methods can be called on any thread without synchronization. TODO: Update the documentation. b/26047732
Modifier and Type | Field and Description |
---|---|
static String |
COLUMN_LOCAL_FILE_PATH
Cursor column to be used for passing the local file path for documents.
|
Constructor and Description |
---|
DocumentArchiveHelper(DocumentsProvider provider,
char idDelimiter)
Creates a helper for handling archived documents.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the helper and disposes all existing archives.
|
void |
closeArchive(String documentId)
Releases resources for an archive with the specified document ID.
|
String |
getDocumentType(String documentId)
Returns a MIME type of a document within an archive.
|
boolean |
isArchivedDocument(String documentId)
Returns true if the passed document ID is for 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.
|
boolean |
isSupportedArchiveType(String mimeType)
Returns true if the passed mime type is supported by the helper.
|
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 final String COLUMN_LOCAL_FILE_PATH
Type: STRING
public DocumentArchiveHelper(DocumentsProvider provider, char idDelimiter)
provider
- Instance of a documents provider which provides archived documents.idDelimiter
- A character used to create document IDs within archives. Can be any
character which is not used in any other document ID. If your provider uses
numbers as document IDs, the delimiter can be eg. a colon. However if your
provider uses paths, then a delimiter can be any character not allowed in the
path, which is often \0.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, 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 boolean isArchivedDocument(String documentId)
public boolean isSupportedArchiveType(String mimeType)
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public void closeArchive(String documentId)
Calling this method is optional. The helper automatically closes the least recently used archives if too many archives are opened.
archiveDocumentId
- ID of the archive file.