public class

AssetsContentProvider

extends ContentProvider
java.lang.Object
   ↳ android.content.ContentProvider
     ↳ com.pspdfkit.media.AssetsContentProvider

Class Overview

A content provider that serves files from the app's assets.

This content provider is registered inside the app's manifest through manifest merging (you don't need to do this manually). The content provider is not exported, so it is not possible for other apps to access the assets.

The providers base URI is content://{$applicationId{@value CONTENT_PROVIDER_AUTHORITY_SUFFIX}}. All asset paths are relative to this URI. If you would like to serve a file videos/movie.mp4 the respective URI would be content://{$applicationId{@value CONTENT_PROVIDER_AUTHORITY_SUFFIX}/videos/movie.mp4}.

Preparing assets

This content provider may only serve uncompressed asset files (caused by a limitation of Android's AssetManager). If you try to access a compressed asset the content provider will throw a FileNotFoundException.

By default the aapt tool will compress all files inside the assets/ folder of your app before copying them to the APK. The only exception for this are files that are already compressed like multimedia files (i.e. video and audio files).

You can disable compression for arbitrary file types by adding this to your build.gradle script:

android {
     aaptOptions {
         // You can also specify other types, even a list of types.
         noCompress "txt"
     
 }
 }

Summary

[Expand]
Inherited Constants
From interface android.content.ComponentCallbacks2
Public Constructors
AssetsContentProvider()
Public Methods
int delete(Uri uri, String s, String[] strings)
static Uri getAuthority(Context context)
Returns an Uri containing the scheme and authority of this content provider.
String getType(Uri uri)
Uri insert(Uri uri, ContentValues contentValues)
boolean onCreate()
AssetFileDescriptor openAssetFile(Uri uri, String mode)
Cursor query(Uri uri, String[] strings, String s, String[] strings1, String s1)
int update(Uri uri, ContentValues contentValues, String s, String[] strings)
[Expand]
Inherited Methods
From class android.content.ContentProvider
From class java.lang.Object
From interface android.content.ComponentCallbacks
From interface android.content.ComponentCallbacks2

Public Constructors

public AssetsContentProvider ()

Public Methods

public int delete (Uri uri, String s, String[] strings)

public static Uri getAuthority (Context context)

Returns an Uri containing the scheme and authority of this content provider.

Parameters
context Context required for building the authority.

public String getType (Uri uri)

public Uri insert (Uri uri, ContentValues contentValues)

public boolean onCreate ()

public AssetFileDescriptor openAssetFile (Uri uri, String mode)

public Cursor query (Uri uri, String[] strings, String s, String[] strings1, String s1)

public int update (Uri uri, ContentValues contentValues, String s, String[] strings)