public class LazyFileProvider
extends android.content.ContentProvider
| Constructor and Description |
|---|
LazyFileProvider() |
| Modifier and Type | Method and Description |
|---|---|
void |
attachInfo(android.content.Context context,
android.content.pm.ProviderInfo info)
After the FileProvider is instantiated, this method is called to provide the system with
information about the provider.
|
int |
delete(android.net.Uri uri,
java.lang.String selection,
java.lang.String[] selectionArgs)
Deletes the file associated with the specified content URI, as
returned by
getUriForFile(). |
java.lang.String |
getType(android.net.Uri uri)
Returns the MIME type of a content URI returned by
getUriForFile(). |
static android.net.Uri |
getUriForFile(android.content.Context context,
java.lang.String authority,
java.io.File file)
Return a content URI for a given
File. |
android.net.Uri |
insert(android.net.Uri uri,
android.content.ContentValues values)
By default, this method throws an
UnsupportedOperationException. |
boolean |
onCreate()
The default FileProvider implementation does not need to be initialized.
|
android.os.ParcelFileDescriptor |
openFile(android.net.Uri uri,
java.lang.String mode)
By default, FileProvider automatically returns the
ParcelFileDescriptor for a file associated with a content://
Uri. |
android.database.Cursor |
query(android.net.Uri uri,
java.lang.String[] projection,
java.lang.String selection,
java.lang.String[] selectionArgs,
java.lang.String sortOrder)
Use a content URI returned by
getUriForFile() to get information about a file
managed by the FileProvider. |
int |
update(android.net.Uri uri,
android.content.ContentValues values,
java.lang.String selection,
java.lang.String[] selectionArgs)
By default, this method throws an
UnsupportedOperationException. |
applyBatch, bulkInsert, call, canonicalize, dump, getCallingPackage, getContext, getPathPermissions, getReadPermission, getStreamTypes, getWritePermission, isTemporary, onConfigurationChanged, onLowMemory, onTrimMemory, openAssetFile, openAssetFile, openFile, openFileHelper, openPipeHelper, openTypedAssetFile, openTypedAssetFile, query, setPathPermissions, setReadPermission, setWritePermission, shutdown, uncanonicalizepublic boolean onCreate()
onCreate in class android.content.ContentProviderpublic void attachInfo(android.content.Context context,
android.content.pm.ProviderInfo info)
attachInfo in class android.content.ContentProvidercontext - A Context for the current component.info - A ProviderInfo for the new provider.public static android.net.Uri getUriForFile(android.content.Context context,
java.lang.String authority,
java.io.File file)
File. Specific temporary
permissions for the content URI can be set with
Context.grantUriPermission(String, Uri, int), or added
to an Intent by calling setData() and then
setFlags(); in both cases, the applicable flags are
Intent.FLAG_GRANT_READ_URI_PERMISSION and
Intent.FLAG_GRANT_WRITE_URI_PERMISSION. A FileProvider can only return a
content Uri for file paths defined in their <paths>
meta-data element. See the Class Overview for more information.context - A Context for the current component.authority - The authority of a android.support.v4.content.FileProvider defined in a
<provider> element in your app's manifest.file - A File pointing to the filename for which you want a
content Uri.java.lang.IllegalArgumentException - When the given File is outside
the paths supported by the provider.public android.database.Cursor query(android.net.Uri uri,
java.lang.String[] projection,
java.lang.String selection,
java.lang.String[] selectionArgs,
java.lang.String sortOrder)
getUriForFile() to get information about a file
managed by the FileProvider.
FileProvider reports the column names defined in OpenableColumns:
OpenableColumns.DISPLAY_NAMEOpenableColumns.SIZEContentProvider.query().query in class android.content.ContentProvideruri - A content URI returned by getUriForFile(android.content.Context, java.lang.String, java.io.File).projection - The list of columns to put into the Cursor. If null all columns are
included.selection - Selection criteria to apply. If null then all data that matches the content
URI is returned.selectionArgs - An array of String, containing arguments to bind to
the selection parameter. The query method scans selection from left to
right and iterates through selectionArgs, replacing the current "?" character in
selection with the value at the current position in selectionArgs. The
values are bound to selection as String values.sortOrder - A String containing the column name(s) on which to sort
the resulting Cursor.Cursor containing the results of the query.public java.lang.String getType(android.net.Uri uri)
getUriForFile().getType in class android.content.ContentProvideruri - A content URI returned by
getUriForFile().application/octet-stream.public android.net.Uri insert(android.net.Uri uri,
android.content.ContentValues values)
UnsupportedOperationException. You must
subclass FileProvider if you want to provide different functionality.insert in class android.content.ContentProviderpublic int update(android.net.Uri uri,
android.content.ContentValues values,
java.lang.String selection,
java.lang.String[] selectionArgs)
UnsupportedOperationException. You must
subclass FileProvider if you want to provide different functionality.update in class android.content.ContentProviderpublic int delete(android.net.Uri uri,
java.lang.String selection,
java.lang.String[] selectionArgs)
getUriForFile(). Notice that this
method does not throw an IOException; you must check its return value.delete in class android.content.ContentProvideruri - A content URI for a file, as returned by
getUriForFile().selection - Ignored. Set to null.selectionArgs - Ignored. Set to null.public android.os.ParcelFileDescriptor openFile(android.net.Uri uri,
java.lang.String mode)
throws java.io.FileNotFoundException
ParcelFileDescriptor for a file associated with a content://
Uri. To get the ParcelFileDescriptor, call
ContentResolver.openFileDescriptor.
To override this method, you must provide your own subclass of FileProvider.
openFile in class android.content.ContentProvideruri - A content URI associated with a file, as returned by
getUriForFile().mode - Access mode for the file. May be "r" for read-only access, "rw" for read and
write access, or "rwt" for read and write access that truncates any existing file.ParcelFileDescriptor with which you can access the file.java.io.FileNotFoundException