title: Android: Understanding the DPI and getting it via code?
body: <p>Can anyone help, i am finding it difficult to get the DPI of a handset, mentally (understanding it)  and get the value in code :-)</p>
  
  <p>For example, it states the density is the following (taken from android docs)</p>
  
  <pre><code>ldpi    Resources for low-density (ldpi) screens (~120dpi).
  mdpi    Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.)
  hdpi    Resources for high-density (hdpi) screens (~240dpi).
  xhdpi   Resources for extra high-density (xhdpi) screens (~320dpi).
  </code></pre>
  
  <p>but why is it only state as ~240dpi, ie. one value? should it not be (for example) a mobile  (samsung galaxy S2) is of  WVGA (800 x 480) (DPI), what does the symbol ~ mean?</p>
  
  <p>So taking a simple example of 800 x 480 (the dpi of a samsung galaxy s2), how is this converted into one of the values above?</p>
  
  <p>I wonder if anyone can help me mentally understand this.</p>
  
  <p>Then later is it possible via code to get the Density Size, DPI (including x and y) via code?</p>
  
  <p>I am a little lost</p>