Exploring Your Resources

Resources are static bits of information held outside the Java/Kotlin source code. As we discussed previously, resources are stored as files under the res/ directory in your source set (e.g., app/src/main/res/). Here is where you will find all your icons and other images, your externalized strings for internationalization, and more.

These are separate from the Java/Kotlin source code not only because they are different in format. They are separate because you can have multiple definitions of a resource, to use in different circumstances. For example, with internationalization, you will have strings for different languages. Your Java/Kotlin code will be able to remain largely oblivious to this, as Android will choose the right resource to use, from all candidates, in a given circumstance (e.g., choose the Spanish string if the device’s locale is set to Spanish).

In this chapter, we will examine the resources in our starter project and what their roles are in Android app development. Later chapters will cover more about these resources and describe other types of resources that your project can have.

What You See in res/

If you look at the app/src/main/res/ directory of your project, you will see a fairly long list of subdirectories:

Resource Directories in Android Studio
Resource Directories in Android Studio

Resources are placed into directory based in part on the resource type. That forms the base name of the directory, such as drawable and layout. Some directories contain a suffix after this, such as the -v24 part of drawable-v24. That suffix indicates a particular resource set, which we will examine more shortly.

But first, we need to talk about API levels.


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.