title: How to determine screen width using layout qualifiers?
body: <p>The recommend way to to provide layouts for different screen widths is to include each screen dependent layout in a folder using the layout-swxxdp qualifier:</p>
  
  <pre><code>res/layout-sw600dp/   # For 7” tablets (600dp wide and bigger)
  res/layout-sw720dp/   # For 10” tablets (720dp wide and bigger)
  res/layout-sw600dp-port/   # For 7” tablets in portrait (600dp wide or bigger)
  res/layout-sw720dp-port/  # For 10” tablets in portrait (720dp wide or bigger)
  </code></pre>
  
  <p>Android automatically inflates the right layout according to the screen width.</p>
  
  <p>That's great that Android can figure out which layout to use, but what if I have screen size dependent Java code in my activity class that I need to run? What would the implementation of the following method look like?</p>
  
  <pre><code>// Returns true if the screen width is 600 dp or more
  is600dp();
  </code></pre>
  
  <p>I've seen methods like this </p>
  
  <pre><code>// Returns true if the screen is at least 
  // approximately 480x640 dp units
  private boolean isLarge(){
      return (this.getResources().getConfiguration().screenLayout
              &amp; Configuration.SCREENLAYOUT_SIZE_MASK)
              &gt;= Configuration.SCREENLAYOUT_SIZE_LARGE;
  }
  </code></pre>
  
  <p>Now what if my device has a 600dp do screen width, but the above method returns false? Android inflates the right layout, but my device specific code doesn't run. </p>
  
  <p>Am I even making sense?</p>