android.support.v4.content
Class FileProvider
java.lang.Object
   android.content.ContentProvider
android.content.ContentProvider
       android.support.v4.content.FileProvider
android.support.v4.content.FileProvider
- All Implemented Interfaces: 
- android.content.ComponentCallbacks, android.content.ComponentCallbacks2
- public class FileProvider 
- extends android.content.ContentProvider
 
Provider to support easy sharing of private files between apps. When paired
 with features like Context.grantUriPermission(String, Uri, int) or
 Intent.FLAG_GRANT_READ_URI_PERMISSION, this provider ensures that
 receiving apps can always open the underlying file.
 
 Apps should generally avoid sending raw filesystem paths across process
 boundaries, since the receiving app may not have the same access as the
 sender. Instead, apps should send Uri backed by a provider like
 FileProvider.
 
 To use this provider, add it to your manifest:
 
 
 
 And define one or more filesystem paths your provider should support in an
 XML resource. This provider will only support files which exist under these
 defined paths.
 
 
 
 Then use getUriForFile(Context, String, File) at runtime to generate
 a Uri backed by the provider. Since the provider is not exported,
 these Uri can only be accessed by other apps when you explicitly
 grant access.
 
| Nested classes/interfaces inherited from class android.content.ContentProvider | 
| android.content.ContentProvider.PipeDataWriter<T> | 
 
 
| Fields inherited from interface android.content.ComponentCallbacks2 | 
| TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN | 
 
 
| Method Summary | 
|  void | attachInfo(android.content.Context context,
           android.content.pm.ProviderInfo info)
 | 
|  int | delete(android.net.Uri uri,
       String selection,
       String[] selectionArgs)
 | 
|  String | getType(android.net.Uri uri)
 | 
| static android.net.Uri | getUriForFile(android.content.Context context,
              String authority,
              File file)Return a
 Urithat provides access to the givenFile. | 
|  android.net.Uri | insert(android.net.Uri uri,
       android.content.ContentValues values)
 | 
|  boolean | onCreate()
 | 
|  android.os.ParcelFileDescriptor | openFile(android.net.Uri uri,
         String mode)
 | 
|  android.database.Cursor | query(android.net.Uri uri,
      String[] projection,
      String selection,
      String[] selectionArgs,
      String sortOrder)
 | 
|  int | update(android.net.Uri uri,
       android.content.ContentValues values,
       String selection,
       String[] selectionArgs)
 | 
 
| Methods inherited from class android.content.ContentProvider | 
| applyBatch, bulkInsert, call, getContext, getPathPermissions, getReadPermission, getStreamTypes, getWritePermission, isTemporary, onConfigurationChanged, onLowMemory, onTrimMemory, openAssetFile, openFileHelper, openPipeHelper, openTypedAssetFile, query, setPathPermissions, setReadPermission, setWritePermission, shutdown | 
 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
 
FileProvider
public FileProvider()
onCreate
public boolean onCreate()
- 
- Specified by:
- onCreatein class- android.content.ContentProvider
 
- 
 
attachInfo
public void attachInfo(android.content.Context context,
                       android.content.pm.ProviderInfo info)
- 
- Overrides:
- attachInfoin class- android.content.ContentProvider
 
- 
 
getUriForFile
public static android.net.Uri getUriForFile(android.content.Context context,
                                            String authority,
                                            File file)
- Return a Urithat provides access to the givenFile. The
 returnedUrican be used with features likeContext.grantUriPermission(String, Uri, int)orIntent.FLAG_GRANT_READ_URI_PERMISSIONto allow other apps to
 access private files. Providers only support files which exist under
 filesystem paths defined in their<meta-data>.
 
- 
- Parameters:
- authority- The authority of a- FileProviderdefined as a- <provider>in your manifest.
- Throws:
- IllegalArgumentException- When the given- Fileis outside
             the paths supported by the provider.
 
query
public android.database.Cursor query(android.net.Uri uri,
                                     String[] projection,
                                     String selection,
                                     String[] selectionArgs,
                                     String sortOrder)
- 
- Specified by:
- queryin class- android.content.ContentProvider
 
- 
 
getType
public String getType(android.net.Uri uri)
- 
- Specified by:
- getTypein class- android.content.ContentProvider
 
- 
 
insert
public android.net.Uri insert(android.net.Uri uri,
                              android.content.ContentValues values)
- 
- Specified by:
- insertin class- android.content.ContentProvider
 
- 
 
update
public int update(android.net.Uri uri,
                  android.content.ContentValues values,
                  String selection,
                  String[] selectionArgs)
- 
- Specified by:
- updatein class- android.content.ContentProvider
 
- 
 
delete
public int delete(android.net.Uri uri,
                  String selection,
                  String[] selectionArgs)
- 
- Specified by:
- deletein class- android.content.ContentProvider
 
- 
 
openFile
public android.os.ParcelFileDescriptor openFile(android.net.Uri uri,
                                                String mode)
                                         throws FileNotFoundException
- 
- Overrides:
- openFilein class- android.content.ContentProvider
 
- 
- Throws:
- FileNotFoundException
 
Copyright © 2013 Marek Kedzierski. All Rights Reserved.