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 (res/) and a directory for assets (assets/). 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 bites. The directories for resources and assets both reside at the top of your project directory, alongside your source code directory (src/).
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 r 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 AssetManager to read the file as a stream of bytes. So keeping files and data in resources (res/) makes them easily accessible.
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. Resources and Internationalization is where you should start, to learn more about how Android utilizes project resources. Then, the Available Resource Types document offers a summary of various resource types and a reference to their specifications.
Except as noted, this content is licensed under Apache 2.0. For details and restrictions, see the Content License. ! Go to top
Was this article helpful?