Working with Android Studio you can, for the most part, ignore the actual file and directory structure and simply add additional resource files using the New Resource File dialog, or for adding locales the Translation Editor described in the next section. Occasionally, however, you will need to find a file and manually edit the directory structure. In particular, there are no commands that allow you to modify the qualifiers associated with a resource file. The simplest solution is to delete the file and re-create it with new qualifiers if necessary. It is also worth mentioning that you can create custom layout files in the same way and that the Layout Editor also has facilities to allow you to clone an existing portrait layout as a landscape layout, for example.
A Simple Localization
Final version in book.
Android Studio Translation Tools
Final version in book.
Summary
Use resources for as much data as you can. It makes it easier to change things.
You can use the Property window to create and use resources or you can edit the XML directly.
There is a wide range of resource types. In addition to layouts and menus, you are certain to use values and drawables.
Drawables are an example of a resource that doesn't use an XML file. You simply copy the graphics resource files into the drawables directory.
You can store simple data types in the values resource directory and this is often a better way to do things than using constants in the code.
The R object is automatically generated and its structure mimics the resource directory structure. For each resource the R object has an integer resource id.
Many methods take a resource's id and retrieve the resource for you. If you want to explicitly access a resource in code then use the methods that the Resources object provides.
Conditional resources allow you to provide resources that suit the current device – locale, screen resolution and so on.
Conditional resources work by applying qualifiers to the names of the directories that hold the resource files.
Android Studio provides a simplified view of conditional resources that groups all variations on a resource file in the same organizational folder. This does not correspond to the file structure, but it is simpler.
You can use the New, Resource File command to create conditional resources.
The Layout Editor lets you select which locale resource is used so that you can work directly with the localized layout.
If you want to localize your app then make use of the Android Studio Translation Editor.