简体   繁体   English

路径“file:/// android_asset /”记录在哪里?

[英]Where is the path “file:///android_asset/” documented?

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. 互联网上有很多页面都在讨论“file:/// android_asset /”路径(有时候会附加一个s ......)来访问assets文件夹。 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? Android团队是否记录了它?

Android being open source its source code is the most accurate documentation. Android是开源的源代码是最准确的文档。 Here's from android.webkit.URLUtil : 这是来自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/";

Strangely, I only found one hit for the following search: 奇怪的是,我只发现了以下搜索中的一个:

That search result is for WebSettings , which mentions the android_asset and android_res paths in passing. 该搜索结果适用于WebSettings ,它提到了android_assetandroid_res路径。

However, I'm sure I have read the "official" documentation for this before... 但是,我确定我之前已经阅读过“官方”文档......

I found this: 我找到了这个:

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

It provides the directory structure of a project. 它提供项目的目录结构。

The interesting part says: 有趣的部分说:

  • assets/ This is empty. assets /这是空的。 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. 您在此处保存的文件将按原样编译为.apk文件,并保留原始文件名。 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. 您可以使用URI以与典型文件系统相同的方式导航此目录,并使用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. res /包含应用程序资源,例如可绘制文件,布局文件和字符串值。 See Application Resources for more information. 有关更多信息,请参阅应用资源

    • anim/ For XML files that are compiled into animation objects. anim /用于编译为动画对象的XML文件。 See the Animation resource type. 请参见动画资源类型。

    • color/ For XML files that describe colors. color /用于描述颜色的XML文件。 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). drawable /用于位图文件(PNG,JPEG或GIF),9-Patch图像文件和描述Drawable形状的XML文件或包含多个状态(normal,pressed或focused)的Drawable对象。 See the Drawable resource type. 请参阅Drawable资源类型。

    • layout/ XML files that are compiled into screen layouts (or part of a screen). 布局/ XML文件,编译为屏幕布局(或屏幕的一部分)。 See the Layout resource type. 请参阅布局资源类型。

    • menu/ For XML files that define application menus. menu /用于定义应用程序菜单的XML文件。 See the Menus resource type. 请参阅菜单资源类型。

    • raw/ For arbitrary raw asset files. raw /用于任意原始资产文件。 Saving asset files here instead of in the assets/ directory only differs in the way that you access them. 在此处而不是在assets /目录中保存资产文件的方式与访问它们的方式不同。 These files are processed by aapt and must be referenced from the application using a resource identifier in the R class. 这些文件由aapt处理,必须使用R类中的资源标识符从应用程序引用。 For example, this is a good place for media, such as MP3 or Ogg files. 例如,这是媒体的好地方,例如MP3或Ogg文件。

    • values/ For XML files that are compiled into many kinds of resource. values /适用于编译为多种资源的XML文件。 Unlike other resources in the res/ directory, resources written to XML files in this folder are not referenced by the file name. 与res /目录中的其他资源不同,写入此文件夹中的XML文件的资源不会被文件名引用。 Instead, the XML element type controls how the resources is defined within them are placed into the R class. 相反,XML元素类型控制如何在其中定义资源放入R类。

    • xml/ For miscellaneous XML files that configure application components. xml /用于配置应用程序组件的其他XML文件。 For example, an XML file that defines a PreferenceScreen, AppWidgetProviderInfo, or Searchability Metadata. 例如,定义PreferenceScreen,AppWidgetProviderInfo或Searchability Metadata的XML文件。 See Application Resources for more information about configuring these application components. 有关配置这些应用程序组件的更多信息,请参阅应用程

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载位于 file:///android_asset/file.html 的网页,因为:net::ERR_FILE_NOT_FOUND - The webpage at file:///android_asset/file.html could not be loaded because: net::ERR_FILE_NOT_FOUND “初始化网络连接时出错:找不到类”,来源:file:///android_asset/www/cordova.js - “Error initializing Network Connection: Class not found”, source: file:///android_asset/www/cordova.js Phonegap:对象xx在文件中没有方法'exec':///android_asset/www/cordova.js - Phonegap: Object xx has no method 'exec' at file:///android_asset/www/cordova.js 无法在文件:///android_asset/www/apis/camera.js:45读取未定义类型的属性“ DATA_URL” - Can not read propery 'DATA_URL' of undefined type at file:///android_asset/www/apis/camera.js:45 错误回调中的错误:TestPlugin2 = ReferenceError:找不到变量:登录文件:///android_asset/www/js/cordova-1.6.1.js:276 - Error in error callback: TestPlugin2 = ReferenceError: Can't find variable: log at file:///android_asset/www/js/cordova-1.6.1.js:276 将捆绑资产的文件路径传递到 Android 上的外部库中 - Passing a file path to a bundled asset into an external library on Android Android [JavaFxPorts]的资产文件夹在哪里 - Where is the asset folder for Android [JavaFxPorts] Hibernate 5属性在哪里记录? - Where are Hibernate 5 properties documented? 如何获取资产文件路径为String? - How I get the asset file path as String? Eclipse配置选项记录在哪里? - Where are Eclipse configuration options documented?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM