• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1page.title=Providing Resources
2parent.title=Application Resources
3parent.link=index.html
4@jd:body
5
6<div id="qv-wrapper">
7<div id="qv">
8  <h2>Quickview</h2>
9  <ul>
10    <li>Different types of resources belong in different subdirectories of {@code res/}</li>
11    <li>Alternative resources provide configuration-specific resource files</li>
12    <li>Always include default resources so your app does not depend on specific
13device configurations</li>
14  </ul>
15  <h2>In this document</h2>
16  <ol>
17    <li><a href="#ResourceTypes">Grouping Resource Types</a></li>
18    <li><a href="#AlternativeResources">Providing Alternative Resources</a>
19      <ol>
20        <li><a href="#QualifierRules">Qualifier name rules</a></li>
21        <li><a href="#AliasResources">Creating alias resources</a></li>
22      </ol>
23    </li>
24    <li><a href="#Compatibility">Providing the Best Device Compatibility with Resources</a></li>
25    <li><a href="#BestMatch">How Android Finds the Best-matching Resource</a></li>
26  </ol>
27
28  <h2>See also</h2>
29  <ol>
30    <li><a href="accessing-resources.html">Accessing Resources</a></li>
31    <li><a href="available-resources.html">Resource Types</a></li>
32    <li><a href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple
33Screens</a></li>
34  </ol>
35</div>
36</div>
37
38<p>You should always externalize application resources such as images and strings from your
39code, so that you can maintain them independently. You should also provide alternative resources for
40specific device configurations, by grouping them in specially-named resource directories. At
41runtime, Android uses the appropriate resource based on the current configuration. For
42example, you might want to provide a different UI layout depending on the screen size or different
43strings depending on the language setting.</p>
44
45<p>Once you externalize your application resources, you can access them
46using resource IDs that are generated in your project's {@code R} class. How to use
47resources in your application is discussed in <a href="accessing-resources.html">Accessing
48Resources</a>. This document shows you how to group your resources in your Android project and
49provide alternative resources for specific device configurations.</p>
50
51
52<h2 id="ResourceTypes">Grouping Resource Types</h2>
53
54<p>You should place each type of resource in a specific subdirectory of your project's
55{@code res/} directory. For example, here's the file hierarchy for a simple project:</p>
56
57<pre class="classic no-pretty-print">
58MyProject/
59    src/  <span style="color:black">
60        MyActivity.java  </span>
61    res/
62        drawable/  <span style="color:black">
63            graphic.png  </span>
64        layout/  <span style="color:black">
65            main.xml
66            info.xml</span>
67        mipmap/  <span style="color:black">
68            icon.png </span>
69        values/  <span style="color:black">
70            strings.xml  </span>
71</pre>
72
73<p>As you can see in this example, the {@code res/} directory contains all the resources (in
74subdirectories): an image resource, two layout resources, {@code mipmap/} directories for launcher
75icons, and a string resource file. The resource
76directory names are important and are described in table 1.</p>
77
78<p class="note"><strong>Note:</strong> For more information about using the mipmap folders, see
79<a href="{@docRoot}tools/projects/index.html#mipmap">Managing Projects Overview</a>.</p>
80
81<p class="table-caption" id="table1"><strong>Table 1.</strong> Resource directories
82supported inside project {@code res/} directory.</p>
83
84<table>
85  <tr>
86    <th scope="col">Directory</th>
87    <th scope="col">Resource Type</th>
88  </tr>
89
90  <tr>
91    <td><code>animator/</code></td>
92    <td>XML files that define <a href="{@docRoot}guide/topics/graphics/prop-animation.html">property
93animations</a>.</td>
94  </tr>
95
96  <tr>
97    <td><code>anim/</code></td>
98    <td>XML files that define <a
99href="{@docRoot}guide/topics/graphics/view-animation.html#tween-animation">tween
100animations</a>. (Property animations can also be saved in this directory, but
101the {@code animator/} directory is preferred for property animations to distinguish between the two
102types.)</td>
103  </tr>
104
105  <tr>
106    <td><code>color/</code></td>
107    <td>XML files that define a state list of colors. See <a href="color-list-resource.html">Color
108State List Resource</a></td>
109  </tr>
110
111  <tr>
112    <td><code>drawable/</code></td>
113
114    <td><p>Bitmap files ({@code .png}, {@code .9.png}, {@code .jpg}, {@code .gif}) or XML files that
115are compiled into the following drawable resource subtypes:</p>
116      <ul>
117        <li>Bitmap files</li>
118        <li>Nine-Patches (re-sizable bitmaps)</li>
119        <li>State lists</li>
120        <li>Shapes</li>
121        <li>Animation drawables</li>
122        <li>Other drawables</li>
123      </ul>
124      <p>See <a href="drawable-resource.html">Drawable Resources</a>.</p>
125    </td>
126  </tr>
127
128  <tr>
129    <td><code>mipmap/</code></td>
130    <td>Drawable files for different launcher icon densities. For more information on managing
131    launcher icons with {@code mipmap/} folders, see
132    <a href="{@docRoot}tools/projects/index.html#mipmap">Managing Projects Overview</a>.</td>
133  </tr>
134
135  <tr>
136    <td><code>layout/</code></td>
137    <td>XML files that define a user interface layout.
138        See <a href="layout-resource.html">Layout Resource</a>.</td>
139  </tr>
140
141  <tr>
142    <td><code>menu/</code></td>
143    <td>XML files that define application menus, such as an Options Menu, Context Menu, or Sub
144Menu. See <a href="menu-resource.html">Menu Resource</a>.</td>
145  </tr>
146
147  <tr>
148    <td><code>raw/</code></td>
149    <td><p>Arbitrary files to save in their raw form. To open these resources with a raw
150{@link java.io.InputStream}, call {@link android.content.res.Resources#openRawResource(int)
151Resources.openRawResource()} with the resource ID, which is <code>R.raw.<em>filename</em></code>.</p>
152      <p>However, if you need access to original file names and file hierarchy, you might consider
153saving some resources in the {@code
154assets/} directory (instead of {@code res/raw/}). Files in {@code assets/} are not given a
155resource ID, so you can read them only using {@link android.content.res.AssetManager}.</p></td>
156  </tr>
157
158  <tr>
159    <td><code>values/</code></td>
160    <td><p>XML files that contain simple values, such as strings, integers, and colors.</p>
161      <p>Whereas XML resource files in other {@code res/} subdirectories define a single resource
162based on the XML filename, files in the {@code values/} directory describe multiple resources.
163For a file in this directory, each child of the {@code <resources>} element defines a single
164resource. For example, a {@code <string>} element creates an
165{@code R.string} resource and a  {@code <color>} element creates an {@code R.color}
166resource.</p>
167      <p>Because each resource is defined with its own XML element, you can name the file
168whatever you want and place different resource types in one file. However, for clarity, you might
169want to place unique resource types in different files. For example, here are some filename
170conventions for resources you can create in this directory:</p>
171      <ul>
172        <li>arrays.xml for resource arrays (<a
173href="more-resources.html#TypedArray">typed arrays</a>).</li>
174        <li>colors.xml for <a
175href="more-resources.html#Color">color values</a></li>
176        <li>dimens.xml for <a
177href="more-resources.html#Dimension">dimension values</a>.</li>
178        <li>strings.xml for <a href="string-resource.html">string
179values</a>.</li>
180        <li>styles.xml for <a href="style-resource.html">styles</a>.</li>
181      </ul>
182      <p>See <a href="string-resource.html">String Resources</a>,
183        <a href="style-resource.html">Style Resource</a>, and
184        <a href="more-resources.html">More Resource Types</a>.</p>
185    </td>
186  </tr>
187
188  <tr>
189    <td><code>xml/</code></td>
190    <td>Arbitrary XML files that can be read at runtime by calling {@link
191android.content.res.Resources#getXml(int) Resources.getXML()}. Various XML configuration files
192must be saved here, such as a <a
193href="{@docRoot}guide/topics/search/searchable-config.html">searchable configuration</a>.
194<!-- or preferences configuration. --></td>
195  </tr>
196</table>
197
198<p class="caution"><strong>Caution:</strong> Never save resource files directly inside the
199{@code res/} directory&mdash;it will cause a compiler error.</p>
200
201<p>For more information about certain types of resources, see the <a
202href="available-resources.html">Resource Types</a> documentation.</p>
203
204<p>The resources that you save in the subdirectories defined in table 1 are your "default"
205resources. That is, these resources define the default design and content for your application.
206However, different types of Android-powered devices might call for different types of resources.
207For example, if a device has a larger than normal screen, then you should provide
208different layout resources that take advantage of the extra screen space. Or, if a device has a
209different language setting, then you should provide different string resources that translate the
210text in your user interface. To provide these different resources for different device
211configurations, you need to provide alternative resources, in addition to your default
212resources.</p>
213
214
215<h2 id="AlternativeResources">Providing Alternative Resources</h2>
216
217
218<div class="figure" style="width:429px">
219<img src="{@docRoot}images/resources/resource_devices_diagram2.png" height="167" alt="" />
220<p class="img-caption">
221<strong>Figure 1.</strong> Two different devices, each using different layout resources.</p>
222</div>
223
224<p>Almost every application should provide alternative resources to support specific device
225configurations. For instance, you should include alternative drawable resources for different
226screen densities and alternative string resources for different languages. At runtime, Android
227detects the current device configuration and loads the appropriate
228resources for your application.</p>
229
230<p>To specify configuration-specific alternatives for a set of resources:</p>
231<ol>
232  <li>Create a new directory in {@code res/} named in the form
233  <code><em>&lt;resources_name&gt;</em>-<em>&lt;config_qualifier&gt;</em></code>.
234    <ul>
235      <li><em>{@code <resources_name>}</em> is the directory name of the corresponding default
236resources (defined in table 1).</li>
237      <li><em>{@code <qualifier>}</em> is a name that specifies an individual configuration
238for which these resources are to be used (defined in table 2).</li>
239    </ul>
240    <p>You can append more than one <em>{@code <qualifier>}</em>. Separate each
241one with a dash.</p>
242    <p class="caution"><strong>Caution:</strong> When appending multiple qualifiers, you must
243place them in the same order in which they are listed in table 2. If the qualifiers are ordered
244wrong, the resources are ignored.</p>
245  </li>
246  <li>Save the respective alternative resources in this new directory. The resource files must be
247named exactly the same as the default resource files.</li>
248</ol>
249
250<p>For example, here are some default and alternative resources:</p>
251
252<pre class="classic no-pretty-print">
253res/
254    drawable/   <span style="color:black">
255        icon.png
256        background.png    </span>
257    drawable-hdpi/  <span style="color:black">
258        icon.png
259        background.png  </span>
260</pre>
261
262<p>The {@code hdpi} qualifier indicates that the resources in that directory are for devices with a
263high-density screen. The images in each of these drawable directories are sized for a specific
264screen density, but the filenames are exactly
265the same. This way, the resource ID that you use to reference the {@code icon.png} or {@code
266background.png} image is always the same, but Android selects the
267version of each resource that best matches the current device, by comparing the device
268configuration information with the qualifiers in the resource directory name.</p>
269
270<p>Android supports several configuration qualifiers and you can
271add multiple qualifiers to one directory name, by separating each qualifier with a dash. Table 2
272lists the valid configuration qualifiers, in order of precedence&mdash;if you use multiple
273qualifiers for a resource directory, you must add them to the directory name in the order they
274are listed in the table.</p>
275
276
277<p class="table-caption" id="table2"><strong>Table 2.</strong> Configuration qualifier
278names.</p>
279<table>
280    <tr>
281        <th>Configuration</th>
282        <th>Qualifier Values</th>
283        <th>Description</th>
284    </tr>
285    <tr id="MccQualifier">
286      <td>MCC and MNC</td>
287      <td>Examples:<br/>
288        <code>mcc310</code><br/>
289        <code><nobr>mcc310-mnc004</nobr></code><br/>
290        <code>mcc208-mnc00</code><br/>
291        etc.
292      </td>
293      <td>
294        <p>The mobile country code (MCC), optionally followed by mobile network code (MNC)
295        from the SIM card in the device. For example, <code>mcc310</code> is U.S. on any carrier,
296        <code>mcc310-mnc004</code> is U.S. on Verizon, and <code>mcc208-mnc00</code> is France on
297        Orange.</p>
298        <p>If the device uses a radio connection (GSM phone), the MCC and MNC values come
299        from the SIM card.</p>
300        <p>You can also use the MCC alone (for example, to include country-specific legal
301resources in your application). If you need to specify based on the language only, then use the
302<em>language and region</em> qualifier instead (discussed next). If you decide to use the MCC and
303MNC qualifier, you should do so with care and test that it works as expected.</p>
304        <p>Also see the configuration fields {@link
305android.content.res.Configuration#mcc}, and {@link
306android.content.res.Configuration#mnc}, which indicate the current mobile country code
307and mobile network code, respectively.</p>
308      </td>
309    </tr>
310    <tr id="LocaleQualifier">
311      <td>Language and region</td>
312      <td>Examples:<br/>
313        <code>en</code><br/>
314        <code>fr</code><br/>
315        <code>en-rUS</code><br/>
316        <code>fr-rFR</code><br/>
317        <code>fr-rCA</code><br/>
318        etc.
319      </td>
320      <td><p>The language is defined by a two-letter <a
321href="http://www.loc.gov/standards/iso639-2/php/code_list.php">ISO
322              639-1</a> language code, optionally followed by a two letter
323              <a
324href="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO
325              3166-1-alpha-2</a> region code (preceded by lowercase &quot;{@code r}&quot;).
326        </p><p>
327        The codes are <em>not</em> case-sensitive; the {@code r} prefix is used to
328        distinguish the region portion.
329        You cannot specify a region alone.</p>
330        <p>This can change during the life
331of your application if the user changes his or her language in the system settings. See <a
332href="runtime-changes.html">Handling Runtime Changes</a> for information about
333how this can affect your application during runtime.</p>
334        <p>See <a href="localization.html">Localization</a> for a complete guide to localizing
335your application for other languages.</p>
336        <p>Also see the {@link android.content.res.Configuration#locale} configuration field, which
337indicates the current locale.</p>
338      </td>
339    </tr>
340    <tr id="LayoutDirectionQualifier">
341      <td>Layout Direction</td>
342      <td><code>ldrtl</code><br/>
343        <code>ldltr</code><br/>
344      </td>
345      <td><p>The layout direction of your application. {@code ldrtl} means "layout-direction-right-to-left".
346      {@code ldltr} means "layout-direction-left-to-right" and is the default implicit value.
347      </p>
348      <p>This can apply to any resource such as layouts, drawables, or values.
349      </p>
350      <p>For example, if you want to provide some specific layout for the Arabic language and some
351      generic layout for any other "right-to-left" language (like Persian or Hebrew) then you would have:
352      </p>
353<pre class="classic no-pretty-print">
354res/
355    layout/   <span style="color:black">
356        main.xml  </span>(Default layout)
357    layout-ar/  <span style="color:black">
358        main.xml  </span>(Specific layout for Arabic)
359    layout-ldrtl/  <span style="color:black">
360        main.xml  </span>(Any "right-to-left" language, except
361                  for Arabic, because the "ar" language qualifier
362                  has a higher precedence.)
363</pre>
364        <p class="note"><strong>Note:</strong> To enable right-to-left layout features
365        for your app, you must set <a
366        href="{@docRoot}guide/topics/manifest/application-element.html#supportsrtl">{@code
367        supportsRtl}</a> to {@code "true"} and set <a
368        href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target"
369        >{@code targetSdkVersion}</a> to 17 or higher.</p>
370        <p><em>Added in API level 17.</em></p>
371      </td>
372    </tr>
373    <tr id="SmallestScreenWidthQualifier">
374      <td>smallestWidth</td>
375      <td><code>sw&lt;N&gt;dp</code><br/><br/>
376        Examples:<br/>
377        <code>sw320dp</code><br/>
378        <code>sw600dp</code><br/>
379        <code>sw720dp</code><br/>
380        etc.
381      </td>
382      <td>
383        <p>The fundamental size of a screen, as indicated by the shortest dimension of the available
384screen area. Specifically, the device's smallestWidth is the shortest of the screen's available
385height and width (you may also think of it as the "smallest possible width" for the screen). You can
386use this qualifier to ensure that, regardless of the screen's current orientation, your
387application has at least {@code <N>} dps of width available for its UI.</p>
388        <p>For example, if your layout requires that its smallest dimension of screen area be at
389least 600 dp at all times, then you can use this qualifer to create the layout resources, {@code
390res/layout-sw600dp/}. The system will use these resources only when the smallest dimension of
391available screen is at least 600dp, regardless of whether the 600dp side is the user-perceived
392height or width. The smallestWidth is a fixed screen size characteristic of the device; <strong>the
393device's smallestWidth does not change when the screen's orientation changes</strong>.</p>
394        <p>The smallestWidth of a device takes into account screen decorations and system UI. For
395example, if the device has some persistent UI elements on the screen that account for space along
396the axis of the smallestWidth, the system declares the smallestWidth to be smaller than the actual
397screen size, because those are screen pixels not available for your UI. Thus, the value you use
398should be the actual smallest dimension <em>required by your layout</em> (usually, this value is the
399"smallest width" that your layout supports, regardless of the screen's current orientation).</p>
400        <p>Some values you might use here for common screen sizes:</p>
401        <ul>
402          <li>320, for devices with screen configurations such as:
403            <ul>
404              <li>240x320 ldpi (QVGA handset)</li>
405              <li>320x480 mdpi (handset)</li>
406              <li>480x800 hdpi (high-density handset)</li>
407            </ul>
408          </li>
409          <li>480, for screens such as 480x800 mdpi (tablet/handset).</li>
410          <li>600, for screens such as 600x1024 mdpi (7" tablet).</li>
411          <li>720, for screens such as 720x1280 mdpi (10" tablet).</li>
412        </ul>
413        <p>When your application provides multiple resource directories with different values for
414        the smallestWidth qualifier, the system uses the one closest to (without exceeding) the
415device's smallestWidth. </p>
416        <p><em>Added in API level 13.</em></p>
417        <p>Also see the <a
418href="{@docRoot}guide/topics/manifest/supports-screens-element.html#requiresSmallest">{@code
419android:requiresSmallestWidthDp}</a> attribute, which declares the minimum smallestWidth with which
420your application is compatible, and the {@link
421android.content.res.Configuration#smallestScreenWidthDp} configuration field, which holds the
422device's smallestWidth value.</p>
423        <p>For more information about designing for different screens and using this
424qualifier, see the <a href="{@docRoot}guide/practices/screens_support.html">Supporting
425Multiple Screens</a> developer guide.</p>
426      </td>
427    </tr>
428    <tr id="ScreenWidthQualifier">
429      <td>Available width</td>
430      <td><code>w&lt;N&gt;dp</code><br/><br/>
431        Examples:<br/>
432        <code>w720dp</code><br/>
433        <code>w1024dp</code><br/>
434        etc.
435      </td>
436      <td>
437        <p>Specifies a minimum available screen width, in {@code dp} units at which the resource
438          should be used&mdash;defined by the <code>&lt;N&gt;</code> value.  This
439          configuration value will change when the orientation
440          changes between landscape and portrait to match the current actual width.</p>
441        <p>When your application provides multiple resource directories with different values
442          for this configuration, the system uses the one closest to (without exceeding)
443          the device's current screen width.  The
444          value here takes into account screen decorations, so if the device has some
445          persistent UI elements on the left or right edge of the display, it
446          uses a value for the width that is smaller than the real screen size, accounting
447          for these UI elements and reducing the application's available space.</p>
448        <p><em>Added in API level 13.</em></p>
449        <p>Also see the {@link android.content.res.Configuration#screenWidthDp}
450          configuration field, which holds the current screen width.</p>
451        <p>For more information about designing for different screens and using this
452qualifier, see the <a href="{@docRoot}guide/practices/screens_support.html">Supporting
453Multiple Screens</a> developer guide.</p>
454      </td>
455    </tr>
456    <tr id="ScreenHeightQualifier">
457      <td>Available height</td>
458      <td><code>h&lt;N&gt;dp</code><br/><br/>
459        Examples:<br/>
460        <code>h720dp</code><br/>
461        <code>h1024dp</code><br/>
462        etc.
463      </td>
464      <td>
465        <p>Specifies a minimum available screen height, in "dp" units at which the resource
466          should be used&mdash;defined by the <code>&lt;N&gt;</code> value.  This
467          configuration value will change when the orientation
468          changes between landscape and portrait to match the current actual height.</p>
469        <p>When your application provides multiple resource directories with different values
470          for this configuration, the system uses the one closest to (without exceeding)
471          the device's current screen height.  The
472          value here takes into account screen decorations, so if the device has some
473          persistent UI elements on the top or bottom edge of the display, it uses
474          a value for the height that is smaller than the real screen size, accounting
475          for these UI elements and reducing the application's available space.  Screen
476          decorations that are not fixed (such as a phone status bar that can be
477          hidden when full screen) are <em>not</em> accounted for here, nor are
478          window decorations like the title bar or action bar, so applications must be prepared to
479          deal with a somewhat smaller space than they specify.
480        <p><em>Added in API level 13.</em></p>
481        <p>Also see the {@link android.content.res.Configuration#screenHeightDp}
482          configuration field, which holds the current screen width.</p>
483        <p>For more information about designing for different screens and using this
484qualifier, see the <a href="{@docRoot}guide/practices/screens_support.html">Supporting
485Multiple Screens</a> developer guide.</p>
486      </td>
487    </tr>
488    <tr id="ScreenSizeQualifier">
489      <td>Screen size</td>
490      <td>
491        <code>small</code><br/>
492        <code>normal</code><br/>
493        <code>large</code><br/>
494        <code>xlarge</code>
495      </td>
496      <td>
497        <ul class="nolist">
498        <li>{@code small}: Screens that are of similar size to a
499        low-density QVGA screen. The minimum layout size for a small screen
500        is approximately 320x426 dp units.  Examples are QVGA low-density and VGA high
501        density.</li>
502        <li>{@code normal}: Screens that are of similar size to a
503        medium-density HVGA screen. The minimum
504        layout size for a normal screen is approximately 320x470 dp units.  Examples
505        of such screens a WQVGA low-density, HVGA medium-density, WVGA
506        high-density.</li>
507        <li>{@code large}: Screens that are of similar size to a
508        medium-density VGA screen.
509        The minimum layout size for a large screen is approximately 480x640 dp units.
510        Examples are VGA and WVGA medium-density screens.</li>
511        <li>{@code xlarge}: Screens that are considerably larger than the traditional
512        medium-density HVGA screen. The minimum layout size for an xlarge screen
513        is approximately 720x960 dp units.  In most cases, devices with extra-large
514        screens would be too large to carry in a pocket and would most likely
515        be tablet-style devices. <em>Added in API level 9.</em></li>
516        </ul>
517        <p class="note"><strong>Note:</strong> Using a size qualifier does not imply that the
518resources are <em>only</em> for screens of that size. If you do not provide alternative
519resources with qualifiers that better match the current device configuration, the system may use
520whichever resources are the <a href="#BestMatch">best match</a>.</p>
521        <p class="caution"><strong>Caution:</strong> If all your resources use a size qualifier that
522is <em>larger</em> than the current screen, the system will <strong>not</strong> use them and your
523application will crash at runtime (for example, if all layout resources are tagged with the {@code
524xlarge} qualifier, but the device is a normal-size screen).</p>
525        <p><em>Added in API level 4.</em></p>
526
527        <p>See <a href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple
528Screens</a> for more information.</p>
529        <p>Also see the {@link android.content.res.Configuration#screenLayout} configuration field,
530which indicates whether the screen is small, normal,
531or large.</p>
532      </td>
533    </tr>
534    <tr id="ScreenAspectQualifier">
535      <td>Screen aspect</td>
536      <td>
537        <code>long</code><br/>
538        <code>notlong</code>
539      </td>
540      <td>
541        <ul class="nolist">
542          <li>{@code long}: Long screens, such as WQVGA, WVGA, FWVGA</li>
543          <li>{@code notlong}: Not long screens, such as QVGA, HVGA, and VGA</li>
544        </ul>
545        <p><em>Added in API level 4.</em></p>
546        <p>This is based purely on the aspect ratio of the screen (a "long" screen is wider). This
547is not related to the screen orientation.</p>
548        <p>Also see the {@link android.content.res.Configuration#screenLayout} configuration field,
549which indicates whether the screen is long.</p>
550      </td>
551    </tr>
552    <tr id="ScreenRoundQualifier">
553      <td>Round screen</td>
554      <td>
555        <code>round</code><br/>
556        <code>notround</code>
557      </td>
558      <td>
559        <ul class="nolist">
560          <li>{@code round}: Round screens, such as a round wearable device</li>
561          <li>{@code notround}: Rectangular screens, such as phones or tablets</li>
562        </ul>
563        <p><em>Added in API level 23.</em></p>
564        <p>Also see the {@link android.content.res.Configuration#isScreenRound()} configuration
565method, which indicates whether the screen is round.</p>
566      </td>
567    </tr>
568    <tr id="OrientationQualifier">
569      <td>Screen orientation</td>
570      <td>
571        <code>port</code><br/>
572        <code>land</code>  <!-- <br/>
573        <code>square</code>  -->
574      </td>
575      <td>
576        <ul class="nolist">
577          <li>{@code port}: Device is in portrait orientation (vertical)</li>
578          <li>{@code land}: Device is in landscape orientation (horizontal)</li>
579          <!-- Square mode is currently not used. -->
580        </ul>
581        <p>This can change during the life of your application if the user rotates the
582screen. See <a href="runtime-changes.html">Handling Runtime Changes</a> for information about
583how this affects your application during runtime.</p>
584        <p>Also see the {@link android.content.res.Configuration#orientation} configuration field,
585which indicates the current device orientation.</p>
586      </td>
587    </tr>
588    <tr id="UiModeQualifier">
589      <td>UI mode</td>
590      <td>
591        <code>car</code><br/>
592        <code>desk</code><br/>
593        <code>television<br/>
594        <code>appliance</code>
595        <code>watch</code>
596      </td>
597      <td>
598        <ul class="nolist">
599          <li>{@code car}: Device is displaying in a car dock</li>
600          <li>{@code desk}: Device is displaying in a desk dock</li>
601          <li>{@code television}: Device is displaying on a television, providing
602          a "ten foot" experience where its UI is on a large screen that the
603          user is far away from, primarily oriented around DPAD or other
604          non-pointer interaction</li>
605          <li>{@code appliance}: Device is serving as an appliance, with
606          no display</li>
607          <li>{@code watch}: Device has a display and is worn on the wrist</li>
608        </ul>
609        <p><em>Added in API level 8, television added in API 13, watch added in API 20.</em></p>
610        <p>For information about how your app can respond when the device is inserted into or
611        removed from a dock, read <a
612        href="{@docRoot}training/monitoring-device-state/docking-monitoring.html">Determining
613and Monitoring the Docking State and Type</a>.</p>
614        <p>This can change during the life of your application if the user places the device in a
615dock. You can enable or disable some of these modes using {@link
616android.app.UiModeManager}. See <a href="runtime-changes.html">Handling Runtime Changes</a> for
617information about how this affects your application during runtime.</p>
618      </td>
619    </tr>
620    <tr id="NightQualifier">
621      <td>Night mode</td>
622      <td>
623        <code>night</code><br/>
624        <code>notnight</code>
625      </td>
626      <td>
627        <ul class="nolist">
628          <li>{@code night}: Night time</li>
629          <li>{@code notnight}: Day time</li>
630        </ul>
631        <p><em>Added in API level 8.</em></p>
632        <p>This can change during the life of your application if night mode is left in
633auto mode (default), in which case the mode changes based on the time of day.  You can enable
634or disable this mode using {@link android.app.UiModeManager}. See <a
635href="runtime-changes.html">Handling Runtime Changes</a> for information about how this affects your
636application during runtime.</p>
637      </td>
638    </tr>
639    <tr id="DensityQualifier">
640      <td>Screen pixel density (dpi)</td>
641      <td>
642        <code>ldpi</code><br/>
643        <code>mdpi</code><br/>
644        <code>hdpi</code><br/>
645        <code>xhdpi</code><br/>
646        <code>xxhdpi</code><br/>
647        <code>xxxhdpi</code><br/>
648        <code>nodpi</code><br/>
649        <code>tvdpi</code><br/>
650        <code>anydpi</code>
651      </td>
652      <td>
653        <ul class="nolist">
654          <li>{@code ldpi}: Low-density screens; approximately 120dpi.</li>
655          <li>{@code mdpi}: Medium-density (on traditional HVGA) screens; approximately
656160dpi.</li>
657          <li>{@code hdpi}: High-density screens; approximately 240dpi.</li>
658          <li>{@code xhdpi}: Extra-high-density screens; approximately 320dpi. <em>Added in API
659Level 8</em></li>
660          <li>{@code xxhdpi}: Extra-extra-high-density screens; approximately 480dpi. <em>Added in API
661Level 16</em></li>
662          <li>{@code xxxhdpi}: Extra-extra-extra-high-density uses (launcher icon only, see the
663            <a href="{@docRoot}guide/practices/screens_support.html#xxxhdpi-note">note</a>
664            in <em>Supporting Multiple Screens</em>); approximately 640dpi. <em>Added in API
665Level 18</em></li>
666          <li>{@code nodpi}: This can be used for bitmap resources that you do not want to be scaled
667to match the device density.</li>
668          <li>{@code tvdpi}: Screens somewhere between mdpi and hdpi; approximately 213dpi. This is
669not considered a "primary" density group. It is mostly intended for televisions and most
670apps shouldn't need it&mdash;providing mdpi and hdpi resources is sufficient for most apps and
671the system will scale them as appropriate. <em>Added in API Level 13</em></li>
672          <li>{@code anydpi}: This qualifier matches all screen densities and takes precedence over
673other qualifiers. This is useful for
674<a href="{@docRoot}training/material/drawables.html#VectorDrawables">vector drawables</a>.
675<em>Added in API Level 21</em></li>
676        </ul>
677        <p>There is a 3:4:6:8:12:16 scaling ratio between the six primary densities (ignoring the
678tvdpi density). So, a 9x9 bitmap in ldpi is 12x12 in mdpi, 18x18 in hdpi, 24x24 in xhdpi and so on.
679</p>
680        <p>If you decide that your image resources don't look good enough on a television or
681other certain devices and want to try tvdpi resources, the scaling factor is 1.33*mdpi. For
682example, a 100px x 100px image for mdpi screens should be 133px x 133px for tvdpi.</p>
683        <p class="note"><strong>Note:</strong> Using a density qualifier does not imply that the
684resources are <em>only</em> for screens of that density. If you do not provide alternative
685resources with qualifiers that better match the current device configuration, the system may use
686whichever resources are the <a href="#BestMatch">best match</a>.</p>
687        <p>See <a href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple
688Screens</a> for more information about how to handle different screen densities and how Android
689might scale your bitmaps to fit the current density.</p>
690       </td>
691    </tr>
692    <tr id="TouchscreenQualifier">
693      <td>Touchscreen type</td>
694      <td>
695        <code>notouch</code><br/>
696        <code>finger</code>
697      </td>
698      <td>
699        <ul class="nolist">
700          <li>{@code notouch}: Device does not have a touchscreen.</li>
701          <li>{@code finger}: Device has a touchscreen that is intended to
702          be used through direction interaction of the user's finger.</li>
703        </ul>
704        <p>Also see the {@link android.content.res.Configuration#touchscreen} configuration field,
705which indicates the type of touchscreen on the device.</p>
706      </td>
707    </tr>
708    <tr id="KeyboardAvailQualifier">
709      <td>Keyboard availability</td>
710      <td>
711        <code>keysexposed</code><br/>
712        <code>keyshidden</code><br/>
713        <code>keyssoft</code>
714      </td>
715      <td>
716        <ul class="nolist">
717          <li>{@code keysexposed}: Device has a keyboard available. If the device has a
718software keyboard enabled (which is likely), this may be used even when the hardware keyboard is
719<em>not</em> exposed to the user, even if the device has no hardware keyboard. If no software
720keyboard is provided or it's disabled, then this is only used when a hardware keyboard is
721exposed.</li>
722          <li>{@code keyshidden}: Device has a hardware keyboard available but it is
723hidden <em>and</em> the device does <em>not</em> have a software keyboard enabled.</li>
724          <li>{@code keyssoft}: Device has a software keyboard enabled, whether it's
725visible or not.</li>
726        </ul>
727        <p>If you provide <code>keysexposed</code> resources, but not <code>keyssoft</code>
728resources, the system uses the <code>keysexposed</code> resources regardless of whether a
729keyboard is visible, as long as the system has a software keyboard enabled.</p>
730        <p>This can change during the life of your application if the user opens a hardware
731keyboard. See <a href="runtime-changes.html">Handling Runtime Changes</a> for information about how
732this affects your application during runtime.</p>
733        <p>Also see the configuration fields {@link
734android.content.res.Configuration#hardKeyboardHidden} and {@link
735android.content.res.Configuration#keyboardHidden}, which indicate the visibility of a hardware
736keyboard and and the visibility of any kind of keyboard (including software), respectively.</p>
737      </td>
738    </tr>
739    <tr id="ImeQualifier">
740      <td>Primary text input method</td>
741      <td>
742        <code>nokeys</code><br/>
743        <code>qwerty</code><br/>
744        <code>12key</code>
745      </td>
746      <td>
747        <ul class="nolist">
748          <li>{@code nokeys}: Device has no hardware keys for text input.</li>
749          <li>{@code qwerty}: Device has a hardware qwerty keyboard, whether it's visible to the
750user
751or not.</li>
752          <li>{@code 12key}: Device has a hardware 12-key keyboard, whether it's visible to the user
753or not.</li>
754        </ul>
755        <p>Also see the {@link android.content.res.Configuration#keyboard} configuration field,
756which indicates the primary text input method available.</p>
757      </td>
758    </tr>
759    <tr id="NavAvailQualifier">
760      <td>Navigation key availability</td>
761      <td>
762        <code>navexposed</code><br/>
763        <code>navhidden</code>
764      </td>
765      <td>
766        <ul class="nolist">
767          <li>{@code navexposed}: Navigation keys are available to the user.</li>
768          <li>{@code navhidden}: Navigation keys are not available (such as behind a closed
769lid).</li>
770        </ul>
771        <p>This can change during the life of your application if the user reveals the navigation
772keys. See <a href="runtime-changes.html">Handling Runtime Changes</a> for
773information about how this affects your application during runtime.</p>
774        <p>Also see the {@link android.content.res.Configuration#navigationHidden} configuration
775field, which indicates whether navigation keys are hidden.</p>
776      </td>
777    </tr>
778    <tr id="NavigationQualifier">
779      <td>Primary non-touch navigation method</td>
780      <td>
781        <code>nonav</code><br/>
782        <code>dpad</code><br/>
783        <code>trackball</code><br/>
784        <code>wheel</code>
785      </td>
786      <td>
787        <ul class="nolist">
788          <li>{@code nonav}: Device has no navigation facility other than using the
789touchscreen.</li>
790          <li>{@code dpad}: Device has a directional-pad (d-pad) for navigation.</li>
791          <li>{@code trackball}: Device has a trackball for navigation.</li>
792          <li>{@code wheel}: Device has a directional wheel(s) for navigation (uncommon).</li>
793        </ul>
794        <p>Also see the {@link android.content.res.Configuration#navigation} configuration field,
795which indicates the type of navigation method available.</p>
796      </td>
797    </tr>
798<!-- DEPRECATED
799    <tr>
800      <td>Screen dimensions</td>
801      <td>Examples:<br/>
802        <code>320x240</code><br/>
803        <code>640x480</code><br/>
804        etc.
805      </td>
806      <td>
807        <p>The larger dimension must be specified first. <strong>This configuration is deprecated
808and should not be used</strong>. Instead use "screen size," "wider/taller screens," and "screen
809orientation" described above.</p>
810      </td>
811    </tr>
812-->
813    <tr id="VersionQualifier">
814      <td>Platform Version (API level)</td>
815      <td>Examples:<br/>
816        <code>v3</code><br/>
817        <code>v4</code><br/>
818        <code>v7</code><br/>
819        etc.</td>
820      <td>
821        <p>The API level supported by the device. For example, <code>v1</code> for API level
8221 (devices with Android 1.0 or higher) and <code>v4</code> for API level 4 (devices with Android
8231.6 or higher). See the <a
824href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#ApiLevels">Android API levels</a> document for more information
825about these values.</p>
826      </td>
827    </tr>
828</table>
829
830
831<p class="note"><strong>Note:</strong> Some configuration qualifiers have been added since Android
8321.0, so not all versions of Android support all the qualifiers. Using a new qualifier implicitly
833adds the platform version qualifier so that older devices are sure to ignore it. For example, using
834a <code>w600dp</code> qualifier will automatically include the <code>v13</code> qualifier, because
835the available-width qualifier was new in API level 13. To avoid any issues, always include a set of
836default resources (a set of resources with <em>no qualifiers</em>). For more information, see the
837section about <a href="#Compatibility">Providing the Best Device Compatibility with
838Resources</a>.</p>
839
840
841
842<h3 id="QualifierRules">Qualifier name rules</h3>
843
844<p>Here are some rules about using configuration qualifier names:</p>
845
846<ul>
847    <li>You can specify multiple qualifiers for a single set of resources, separated by dashes. For
848example, <code>drawable-en-rUS-land</code> applies to US-English devices in landscape
849orientation.</li>
850    <li>The qualifiers must be in the order listed in <a href="#table2">table 2</a>. For
851example:
852      <ul>
853        <li>Wrong: <code>drawable-hdpi-port/</code></li>
854        <li>Correct: <code>drawable-port-hdpi/</code></li>
855      </ul>
856    </li>
857    <li>Alternative resource directories cannot be nested. For example, you cannot have
858<code>res/drawable/drawable-en/</code>.</li>
859    <li>Values are case-insensitive.  The resource compiler converts directory names
860    to lower case before processing to avoid problems on case-insensitive
861    file systems. Any capitalization in the names is only to benefit readability.</li>
862    <li>Only one value for each qualifier type is supported. For example, if you want to use
863the same drawable files for Spain and France, you <em>cannot</em> have a directory named
864<code>drawable-rES-rFR/</code>. Instead you need two resource directories, such as
865<code>drawable-rES/</code> and <code>drawable-rFR/</code>, which contain the appropriate files.
866However, you are not required to actually duplicate the same files in both locations. Instead, you
867can create an alias to a resource. See <a href="#AliasResources">Creating
868alias resources</a> below.</li>
869</ul>
870
871<p>After you save alternative resources into directories named with
872these qualifiers, Android automatically applies the resources in your application based on the
873current device configuration. Each time a resource is requested, Android checks for alternative
874resource directories that contain the requested resource file, then <a href="#BestMatch">finds the
875best-matching resource</a> (discussed below). If there are no alternative resources that match
876a particular device configuration, then Android uses the corresponding default resources (the
877set of resources for a particular resource type that does not include a configuration
878qualifier).</p>
879
880
881
882<h3 id="AliasResources">Creating alias resources</h3>
883
884<p>When you have a resource that you'd like to use for more than one device
885configuration (but do not want to provide as a default resource), you do not need to put the same
886resource in more than one alternative resource directory. Instead, you can (in some cases) create an
887alternative
888resource that acts as an alias for a resource saved in your default resource directory.</p>
889
890<p class="note"><strong>Note:</strong> Not all resources offer a mechanism by which you can
891create an alias to another resource. In particular, animation, menu, raw, and other unspecified
892resources in the {@code xml/} directory do not offer this feature.</p>
893
894<p>For example, imagine you have an application icon, {@code icon.png}, and need unique version of
895it for different locales. However, two locales, English-Canadian and French-Canadian, need to
896use the same version. You might assume that you need to copy the same image
897into the resource directory for both English-Canadian and French-Canadian, but it's
898not true. Instead, you can save the image that's used for both as {@code icon_ca.png} (any
899name other than {@code icon.png}) and put
900it in the default {@code res/drawable/} directory. Then create an {@code icon.xml} file in {@code
901res/drawable-en-rCA/} and {@code res/drawable-fr-rCA/} that refers to the {@code icon_ca.png}
902resource using the {@code <bitmap>} element. This allows you to store just one version of the
903PNG file and two small XML files that point to it. (An example XML file is shown below.)</p>
904
905
906<h4>Drawable</h4>
907
908<p>To create an alias to an existing drawable, use the {@code <bitmap>} element.
909For example:</p>
910
911<pre>
912&lt;?xml version="1.0" encoding="utf-8"?>
913&lt;bitmap xmlns:android="http://schemas.android.com/apk/res/android"
914    android:src="@drawable/icon_ca" />
915</pre>
916
917<p>If you save this file as {@code icon.xml} (in an alternative resource directory, such as
918{@code res/drawable-en-rCA/}), it is compiled into a resource that you
919can reference as {@code R.drawable.icon}, but is actually an alias for the {@code
920R.drawable.icon_ca} resource (which is saved in {@code res/drawable/}).</p>
921
922
923<h4>Layout</h4>
924
925<p>To create an alias to an existing layout, use the {@code <include>}
926element, wrapped in a {@code <merge>}. For example:</p>
927
928<pre>
929&lt;?xml version="1.0" encoding="utf-8"?>
930&lt;merge>
931    &lt;include layout="@layout/main_ltr"/>
932&lt;/merge>
933</pre>
934
935<p>If you save this file as {@code main.xml}, it is compiled into a resource you can reference
936as {@code R.layout.main}, but is actually an alias for the {@code R.layout.main_ltr}
937resource.</p>
938
939
940<h4>Strings and other simple values</h4>
941
942<p>To create an alias to an existing string, simply use the resource ID of the desired
943string as the value for the new string. For example:</p>
944
945<pre>
946&lt;?xml version="1.0" encoding="utf-8"?>
947&lt;resources>
948    &lt;string name="hello">Hello&lt;/string>
949    &lt;string name="hi">@string/hello&lt;/string>
950&lt;/resources>
951</pre>
952
953<p>The {@code R.string.hi} resource is now an alias for the {@code R.string.hello}.</p>
954
955<p> <a href="{@docRoot}guide/topics/resources/more-resources.html">Other simple values</a> work the
956same way. For example, a color:</p>
957
958<pre>
959&lt;?xml version="1.0" encoding="utf-8"?>
960&lt;resources>
961    &lt;color name="red">#f00&lt;/color>
962    &lt;color name="highlight">@color/red&lt;/color>
963&lt;/resources>
964</pre>
965
966
967
968
969<h2 id="Compatibility">Providing the Best Device Compatibility with Resources</h2>
970
971<p>In order for your application to support multiple device configurations, it's very important that
972you always provide default resources for each type of resource that your application uses.</p>
973
974<p>For example, if your application supports several languages, always include a {@code
975values/} directory (in which your strings are saved) <em>without</em> a <a
976href="#LocaleQualifier">language and region qualifier</a>. If you instead put all your string files
977in directories that have a language and region qualifier, then your application will crash when run
978on a device set to a language that your strings do not support. But, as long as you provide default
979{@code values/} resources, then your application will run properly (even if the user doesn't
980understand that language&mdash;it's better than crashing).</p>
981
982<p>Likewise, if you provide different layout resources based on the screen orientation, you should
983pick one orientation as your default. For example, instead of providing layout resources in {@code
984layout-land/} for landscape and {@code layout-port/} for portrait, leave one as the default, such as
985{@code layout/} for landscape and {@code layout-port/} for portrait.</p>
986
987<p>Providing default resources is important not only because your application might run on a
988configuration you had not anticipated, but also because new versions of Android sometimes add
989configuration qualifiers that older versions do not support. If you use a new resource qualifier,
990but maintain code compatibility with older versions of Android, then when an older version of
991Android runs your application, it will crash if you do not provide default resources, because it
992cannot use the resources named with the new qualifier. For example, if your <a
993href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code
994minSdkVersion}</a> is set to 4, and you qualify all of your drawable resources using <a
995href="#NightQualifier">night mode</a> ({@code night} or {@code notnight}, which were added in API
996Level 8), then an API level 4 device cannot access your drawable resources and will crash. In this
997case, you probably want {@code notnight} to be your default resources, so you should exclude that
998qualifier so your drawable resources are in either {@code drawable/} or {@code drawable-night/}.</p>
999
1000<p>So, in order to provide the best device compatibility, always provide default
1001resources for the resources your application needs to perform properly. Then create alternative
1002resources for specific device configurations using the configuration qualifiers.</p>
1003
1004<p>There is one exception to this rule: If your application's <a
1005href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code minSdkVersion}</a> is 4 or
1006greater, you <em>do not</em> need default drawable resources when you provide alternative drawable
1007resources with the <a href="#DensityQualifier">screen density</a> qualifier. Even without default
1008drawable resources, Android can find the best match among the alternative screen densities and scale
1009the bitmaps as necessary. However, for the best experience on all types of devices, you should
1010provide alternative drawables for all three types of density.</p>
1011
1012
1013
1014<h2 id="BestMatch">How Android Finds the Best-matching Resource</h2>
1015
1016<p>When you request a resource for which you provide alternatives, Android selects which
1017alternative resource to use at runtime, depending on the current device configuration. To
1018demonstrate how Android selects an alternative resource, assume the following drawable directories
1019each contain different versions of the same images:</p>
1020
1021<pre class="classic no-pretty-print">
1022drawable/
1023drawable-en/
1024drawable-fr-rCA/
1025drawable-en-port/
1026drawable-en-notouch-12key/
1027drawable-port-ldpi/
1028drawable-port-notouch-12key/
1029</pre>
1030
1031<p>And assume the following is the device configuration:</p>
1032
1033<p style="margin-left:1em;">
1034Locale = <code>en-GB</code> <br/>
1035Screen orientation = <code>port</code> <br/>
1036Screen pixel density = <code>hdpi</code> <br/>
1037Touchscreen type = <code>notouch</code> <br/>
1038Primary text input method = <code>12key</code>
1039</p>
1040
1041<p>By comparing the device configuration to the available alternative resources, Android selects
1042drawables from {@code drawable-en-port}.</p>
1043
1044<p>The system arrives at its decision for which resources to use with the following
1045logic:</p>
1046
1047
1048<div class="figure" style="width:371px">
1049<img src="{@docRoot}images/resources/res-selection-flowchart.png" alt="" height="471" />
1050<p class="img-caption"><strong>Figure 2.</strong> Flowchart of how Android finds the
1051best-matching resource.</p>
1052</div>
1053
1054
1055<ol>
1056  <li>Eliminate resource files that contradict the device configuration.
1057    <p>The <code>drawable-fr-rCA/</code> directory is eliminated, because it
1058contradicts the <code>en-GB</code> locale.</p>
1059<pre class="classic no-pretty-print">
1060drawable/
1061drawable-en/
1062<strike>drawable-fr-rCA/</strike>
1063drawable-en-port/
1064drawable-en-notouch-12key/
1065drawable-port-ldpi/
1066drawable-port-notouch-12key/
1067</pre>
1068<p class="note"><strong>Exception:</strong> Screen pixel density is the one qualifier that is not
1069eliminated due to a contradiction. Even though the screen density of the device is hdpi,
1070<code>drawable-port-ldpi/</code> is not eliminated because every screen density is
1071considered to be a match at this point. More information is available in the <a
1072href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple
1073Screens</a> document.</p></li>
1074
1075  <li>Pick the (next) highest-precedence qualifier in the list (<a href="#table2">table 2</a>).
1076(Start with MCC, then move down.) </li>
1077  <li>Do any of the resource directories include this qualifier?  </li>
1078    <ul>
1079      <li>If No, return to step 2 and look at the next qualifier. (In the example,
1080  the answer is &quot;no&quot; until the language qualifier is reached.)</li>
1081      <li>If Yes, continue to step 4.</li>
1082    </ul>
1083  </li>
1084
1085  <li>Eliminate resource directories that do not include this qualifier. In the example, the system
1086eliminates all the directories that do not include a language qualifier:</li>
1087<pre class="classic no-pretty-print">
1088<strike>drawable/</strike>
1089drawable-en/
1090drawable-en-port/
1091drawable-en-notouch-12key/
1092<strike>drawable-port-ldpi/</strike>
1093<strike>drawable-port-notouch-12key/</strike>
1094</pre>
1095<p class="note"><strong>Exception:</strong> If the qualifier in question is screen pixel density,
1096Android selects the option that most closely matches the device screen density.
1097In general, Android prefers scaling down a larger original image to scaling up a smaller
1098original image. See <a href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple
1099Screens</a>.</p>
1100  </li>
1101
1102  <li>Go back and repeat steps 2, 3, and 4 until only one directory remains. In the example, screen
1103orientation is the next qualifier for which there are any matches.
1104So, resources that do not specify a screen orientation are eliminated:
1105<pre class="classic no-pretty-print">
1106<strike>drawable-en/</strike>
1107drawable-en-port/
1108<strike>drawable-en-notouch-12key/</strike>
1109</pre>
1110<p>The remaining directory is {@code drawable-en-port}.</p>
1111  </li>
1112</ol>
1113
1114<p>Though this procedure is executed for each resource requested, the system further optimizes
1115some aspects. One such optimization is that once the device configuration is known, it might
1116eliminate alternative resources that can never match. For example, if the configuration
1117language is English ("en"), then any resource directory that has a language qualifier set to
1118something other than English is never included in the pool of resources checked (though a
1119resource directory <em>without</em> the language qualifier is still included).</p>
1120
1121<p>When selecting resources based on the screen size qualifiers, the system will use resources
1122designed for a screen smaller than the current screen if there are no resources that better match
1123(for example, a large-size screen will use normal-size screen resources if necessary). However, if
1124the only available resources are <em>larger</em> than the current screen, the system will
1125<strong>not</strong> use them and your application will crash if no other resources match the device
1126configuration (for example, if all layout resources are tagged with the {@code xlarge} qualifier,
1127but the device is a normal-size screen).</p>
1128
1129<p class="note"><strong>Note:</strong> The <em>precedence</em> of the qualifier (in <a
1130href="#table2">table 2</a>) is more important
1131than the number of qualifiers that exactly match the device. For example, in step 4 above, the last
1132choice on the list includes three qualifiers that exactly match the device (orientation, touchscreen
1133type, and input method), while <code>drawable-en</code> has only one parameter that matches
1134(language). However, language has a higher precedence than these other qualifiers, so
1135<code>drawable-port-notouch-12key</code> is out.</p>
1136
1137<p>To learn more about how to use resources in your application, continue to <a
1138href="accessing-resources.html">Accessing Resources</a>.</p>
1139