<p>More typically, you will only specify a few specific configuration options
that a resource is defined for. You may drop any of the values from the
<p>More typically, you will only specify a few specific configuration options. You may drop any of the values from the
complete list, as long as the remaining values are still in the same
order:</p>
@@ -457,24 +456,28 @@ MyApp/
drawable-port-160dpi/
drawable-qwerty/
</pre>
<p>Table 2 lists the valid folder-name qualifiers, in order of precedence. Qualifiers that are listed higher in the table take precedence over those listed lower, as described in <a href="#best-match">How Android finds the best matching directory</a>. </p>
<p class="caption" id="table2">Table 2</p>
<table border="1">
<tr>
<th> Qualifier </th>
<th> Values </th>
</tr>
<tr>
<td>Language</td>
<td>The two letter <a href="http://www.loc.gov/standards/iso639-2/php/code_list.php">ISO
639-1</a> language code in lowercase. For example:
<td>The mobile country code and mobile network code from the SIM in the device. For example <code>mcc310-mnc004</code> (U.S., Verizon brand); <code>mcc208-mnc00</code> (France, Orange brand); <code>mcc234-mnc00</code> (U.K., BT brand). <br>
<br>
If the device uses a radio connection (GSM phone), the MCC will come from the SIM, and the MNC will come from the network to which the device is attached. You might sometimes use the MCC alone, for example to include country-specific legal resources in your application. If your application specifies resources for a MCC/MNC combination, those resources can only be used if both the MCC and the MNC match. </td>
</tr>
<tr>
<td>Region</td>
<td>The two letter
<td>Language and region</td>
<td>The two letter <a href="http://www.loc.gov/standards/iso639-2/php/code_list.php">ISO
The codes are case-sensitive: The language code is lowercase, and the country code is uppercase. You cannot specify a region alone, but you can specify a language alone, for example <code>en</code>, <code>fr</code>, <code>es</code>. </td>
</tr>
<tr>
<td>Screen orientation</td>
@@ -482,7 +485,7 @@ MyApp/
</tr>
<tr>
<td>Screen pixel density</td>
<td><code>92dpi</code>, <code>108dpi</code>, etc. </td>
<td><code>92dpi</code>, <code>108dpi</code>, etc. When Android selects which resource files to use, it handles screen density differently than the other qualifiers. In step 1 of <a href="#best-match">How Android finds the best matching directory</a> (below), screen density is always considered to be a match. In step 4, if the qualifier being considered is screen density, Android will select the best final match at that point, without any need to move on to step 5. </td>
</tr>
<tr>
<td>Touchscreen type</td>
@@ -490,7 +493,8 @@ MyApp/
</tr>
<tr>
<td>Whether the keyboard is available to the user</td>
If your application has specific resources that should only be used with a soft keyboard, use the <code>keyssoft</code> value. If no <code>keyssoft</code> resources are available (only <code>keysexposed</code> and <code>keyshidden</code>) and the device shows a soft keyboard, the system will use <code>keysexposed</code> resources. </td>
</tr>
<tr>
<td>Primary text input method</td>
@@ -506,6 +510,14 @@ MyApp/
<td><code>320x240</code>, <code>640x480</code>, etc. The larger dimension
must be specified first. </td>
</tr>
<tr>
<td>SDK version</td>
<td>The SDK version supported by the device, for example <code>v3</code>. The Android 1.0 SDK is <code>v1, </code> the 1.1 SDK is <code>v2</code>, and the 1.5 SDK is <code>v3</code>.</td>
</tr>
<tr>
<td>(Minor version)</td>
<td>(You cannot currently specify minor version. It is always set to 0.)</td>
</tr>
</table>
<p>This list does not include device-specific parameters such as carrier,
@@ -513,92 +525,84 @@ branding, device/hardware, or manufacturer. Everything that an application
needs to know about the device that it is running on is encoded via the
resource qualifiers in the table above.</p>
<p>Here are some general guidelines on qualified resource directory names:</p>
<p>All resource directories, qualified and unqualified, live under the <code>res/</code> folder. Here are some guidelines on qualified resource directory names:</p>
<ul>
<li>Values are separated by a dash (as well as a dash after the base directory
name) </li>
<li>Values are case-sensitive (even though they must be unique across all folder
names in a case-insensitive way)<br />For example,</li>
<li>You can specify multiple qualifiers, separated by dashes. For example, <code>drawable-en-rUS-land</code> will apply to US-English
devices in landscape orientation. </li>
<li>The qualifiers must be in the order listed in <a href="#table2">Table 2</a> above. For example:
<ul>
<li>A portrait-specific <code>drawable</code> directory must be named
<code>drawable-port</code>, not <code>drawable-PORT</code>.</li>
<li>You may not have two directories named <code>drawable-port</code>
and <code>drawable-PORT</code>, even if you had intended "port" and
"PORT" to refer to different parameter values.</li>
<li>Values are case-sensitive. For example, a portrait-specific <code>drawable</code> directory must be named
<code>drawable-port</code>, not <code>drawable-PORT</code> or <code>drawable-Port</code>.</li>
<li>Only one value for each qualifier type is supported. For example, if you want to use exactly the same drawable files for Spain and France, you will need two resource directories, such as <code>drawable-rES/</code> and <code>drawable-rFR/</code>, containing identical files. You cannot
have a directory named <code>drawable-rES-rFR/</code>. </li>
<li>Qualified directories cannot be nested. For example, you cannot have <code>res/drawable/drawable-en</code>. </li>
</ul>
<h3>How Android finds the best matching directory </h3>
<h3>How resources are referenced in code</h3>
<p>All resources will be referenced in code or resource reference syntax by
their simple, undecorated names. So if a resource were named this:<br />
device configuration. For example, assume that the following resource directories are available for drawables. The <code>drawable-fr-rCA/</code> directory will be eliminated, because it contradicts the locale of the device.<br>
<pre>MyApp/res/drawable/
MyApp/res/drawable-en/
<strike>MyApp/res/drawable-fr-rCA/</strike>
MyApp/res/drawable-en-port/
MyApp/res/drawable-en-notouch-12key/
MyApp/res/drawable-port-92dpi/
MyApp/res/drawable-port-notouch-12key</pre>
<strong>Exception: </strong>Screen pixel density is the one qualifier that is not used to eliminate files. Even though the screen density of the device is 108 dpi, <code>drawable-port-92dpi/</code> is not eliminated from the list, because every screen density is considered to be a
match at this point.</li>
<li>From <a href="#table2">Table 2</a>, pick the highest-precedence qualifier that remains in the list. (Start with MCC, then move down through the list.) </li>
<li>Do any of the available resource directories include this qualifier? </li>
<ul>
<li>If No, return to step 2 and look at the next qualifier listed in Table 2. In our example, the answer is "no" until we reach Language.</li>
<li>If Yes, move on to step 4.</li>
</ul>
<li>Eliminate resource directories that do not include this qualifier. In our example, we eliminate all the directories that do not include a language qualifier. </li>
<strong>Exception:</strong> If the qualifier in question is screen pixel density, Android will select the option that most closely matches the device, and the selection process will be complete. In general, Android will prefer scaling down a larger original image to scaling up a smaller original image.<br><br></li>
<li>Go back and repeat steps 2, 3, and 4 until only one choice remains. In the example, screen orientation is the next qualifier in the table for which we have any matches.
Eliminate resources that do not specify a screen orientation. </p>
Only one choice remains, so that's it. When drawables are called for in this example application, the Android system will load resources from the <code>MyApp/res/drawable-en-port/</code> directory.
</ol>
<a name="ResourcesTerminology"></a>
<h2>Terminology</h2>
<p class="note"><strong>Tip:</strong> The <em>precedence</em> of the qualifiers is more important than the number of qualifiers that exactly match the device. For example, in step 4 above, the last choice on the list includes three qualifiers that exactly match the device (orientation, touchscreen type, and input method), while <code>drawable-en</code> has only one parameter that matches (language). However, language has a higher precedence, so <code>drawable-port-notouch-12key</code> is out.</p>
<p>This flowchart summarizes how Android selects resource directories to load.</p>