| page.title=Resources and Assets |
| @jd:body |
| |
| <div id="qv-wrapper"> |
| <div id="qv"> |
| |
| <h2>Key classes</h2> |
| <ol> |
| <li>{@link android.content.res.Resources}</li> |
| <li>{@link android.content.res.AssetManager}</li> |
| </ol> |
| |
| </div> |
| </div> |
| |
| <p>Resources are an integral part of an Android application. |
| In general, these are external elements that you want to include and reference within your application, |
| like images, audio, video, text strings, layouts, themes, etc. Every Android application contains |
| a directory for resources (<code>res/</code>) and a directory for assets (<code>assets/</code>). |
| Assets are used less often, because their applications are far fewer. You only need to save data |
| as an asset when you need to read the raw bytes. The directories for resources and assets both |
| reside at the top of an Android project tree, at the same level as your source code directory |
| (<code>src/</code>).</p> |
| |
| <p>The difference between "resources" and "assets" isn't much on the surface, but in general, |
| you'll use resources to store your external content much more often than you'll use assets. |
| The real difference is that anything |
| placed in the resources directory will be easily accessible from your application from the |
| <code>R</code> class, which is compiled by Android. Whereas, anything placed in the assets |
| directory will maintain its raw file format and, in order to read it, you must use the |
| {@link android.content.res.AssetManager} to read the file as a stream of bytes. So keeping |
| files and data in resources (<code>res/</code>) makes them easily accessible.</p> |
| |
| <p>Within the documents of this topic, you'll find information on the kinds of standard resources |
| that are typically used in an Android application and how to reference them from you code. |
| <a href="{@docRoot}guide/topics/resources/resources-i18n.html">Resources and Internationalization</a> |
| is where you should start, to learn more about how Android utilizes project resources. Then, the |
| <a href="{@docRoot}guide/topics/resources/available-resources.html">Available Resource Types</a> |
| document offers a summary of various resource types and a reference to their specifications. |
| </p> |