j2emanue
j2emanue

Reputation: 62519

android values folder item naming convention

I've come across some android native code where the strings.xml in android would be named strings-global.xml and likewise the styles.xml would instead be called styles-global.xml. how is android identifying this ? what does it mean ?

Upvotes: 0

Views: 315

Answers (1)

Bryan Herbst
Bryan Herbst

Reputation: 67189

The naming of files within the values\ folder is arbitrary. What resources the file provides is defined by the contents of the file itself, not the name. Which resources are used in a given configuration is determined by qualifiers on the values\ folder (e.g. values-fr), not the file name.

You could even mix and match resource types in a single file if you really wanted to, though I recommend following convention.

From the Providing Resources documentation for the values\ folder:

Because each resource is defined with its own XML element, you can name the file whatever you want and place different resource types in one file. However, for clarity, you might want to place unique resource types in different files.

In this case, it sounds like the developers discovered that their styles.xml was getting too large and/or they found that they had a few distinct categories of styles that they wanted to separate, and thus put them in different files to keep them more organized.

Upvotes: 3

Related Questions