Back to Fresco

Supported URIs

docs/_docs/supported-uris.md

3.6.02.7 KB
Original Source

Fresco supports images in a variety of locations. Fresco does not accept relative URIs. All URIs must be absolute and must include the scheme.

These are the URI schemes accepted:

TypeSchemeFetch method used
File on networkhttp://, https://HttpURLConnection or network layer
File on devicefile://FileInputStream
Content providercontent://ContentResolver
Asset in appasset://AssetManager
Resource in appres:// as in res:///12345Resources.openRawResource
Data in URIdata:mime/type;base64,Following data URI spec (UTF-8 only)

Note: Only image resources can be used with the image pipeline (e.g. a PNG image). Other resource types such as Strings or XML Drawables make no sense in the context of the image pipeline and so cannot be supported by definition. One potentially confusing case is drawable declared in XML (e.g. ShapeDrawable). Important thing to note is that this is not an image. If you want to display an XML drawable as the main image, then set it as a placeholder and use the null uri.

Sample: Loading an URI

For a sample that just loads an URI see the DraweeSimpleFragment in the showcase app: DraweeSimpleFragment.java

Sample: Loading a Local File

For a sample on how to correctly load user-selected files (e.g. using the content:// URI) see the DraweeMediaPickerFragment in the showcase app: DraweeMediaPickerFragment.java

Sample: Loading a Data URI

The Fresco showcase app has a ImageFormatDataUriFragment that demonstrates using placeholder, failure and retry images.

More

Tip: You can override the displayed image URI in many samples in the showcase app by using the URI Override option in the global settings: