Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the path "file:///android_asset/" documented?

Tags:

java

android

There's a number of pages on the Internet talking about the "file:///android_asset/" path (sometimes with an s appended to the end...) for accessing the assets folder. I am unable to find any kind of official or trustworthy documentation on this path/feature.

Is there any proper documentation for this path? Did the Android team document it?

like image 542
Cornstalks Avatar asked Nov 30 '12 04:11

Cornstalks


3 Answers

Android being open source its source code is the most accurate documentation. Here's from android.webkit.URLUtil:

// to refer to bar.png under your package's asset/foo/ directory, use
// "file:///android_asset/foo/bar.png".
static final String ASSET_BASE = "file:///android_asset/";
// to refer to bar.png under your package's res/drawable/ directory, use
// "file:///android_res/drawable/bar.png". Use "drawable" to refer to
// "drawable-hdpi" directory as well.
static final String RESOURCE_BASE = "file:///android_res/";
like image 112
laalto Avatar answered Nov 12 '22 13:11

laalto


Strangely, I only found one hit for the following search:

  • "android_asset" site:android.com

That search result is for WebSettings, which mentions the android_asset and android_res paths in passing.

However, I'm sure I have read the "official" documentation for this before...

like image 32
Greg Hewgill Avatar answered Nov 12 '22 12:11

Greg Hewgill


I found this:

http://developer.android.com/tools/projects/index.html

It provides the directory structure of a project.

The interesting part says:

  • assets/ This is empty. You can use it to store raw asset files. Files that you save here are compiled into an .apk file as-is, and the original filename is preserved. You can navigate this directory in the same way as a typical file system using URIs and read files as a stream of bytes using the AssetManager. For example, this is a good location for textures and game data.

  • res/ Contains application resources, such as drawable files, layout files, and string values. See Application Resources for more information.

    • anim/ For XML files that are compiled into animation objects. See the Animation resource type.

    • color/ For XML files that describe colors. See the Color Values resource type.

    • drawable/ For bitmap files (PNG, JPEG, or GIF), 9-Patch image files, and XML files that describe Drawable shapes or Drawable objects that contain multiple states (normal, pressed, or focused). See the Drawable resource type.

    • layout/ XML files that are compiled into screen layouts (or part of a screen). See the Layout resource type.

    • menu/ For XML files that define application menus. See the Menus resource type.

    • raw/ For arbitrary raw asset files. Saving asset files here instead of in the assets/ directory only differs in the way that you access them. These files are processed by aapt and must be referenced from the application using a resource identifier in the R class. For example, this is a good place for media, such as MP3 or Ogg files.

    • values/ For XML files that are compiled into many kinds of resource. Unlike other resources in the res/ directory, resources written to XML files in this folder are not referenced by the file name. Instead, the XML element type controls how the resources is defined within them are placed into the R class.

    • xml/ For miscellaneous XML files that configure application components. For example, an XML file that defines a PreferenceScreen, AppWidgetProviderInfo, or Searchability Metadata. See Application Resources for more information about configuring these application components.

like image 2
amoyano Avatar answered Nov 12 '22 13:11

amoyano