How to get screen DPI
<p>I'm trying to get the screen's dpi but so far it isn't working. I tried:</p>

<pre><code>    DisplayMetrics dm = new DisplayMetrics();
    mainContext.getWindowManager().getDefaultDisplay().getMetrics(dm);
    SCREEN_DPI = dm.densityDpi;
</code></pre>

<p>But both on Samsung Galaxy Tab 10.1 and on Samsung Galaxy S I9000 the SCREEN_DPI is equal to 160. I also tried <code>SCREEN_DPI = dm.density</code>, but I get the value <code>1.0</code> to both cases.</p>

<p>Any help would be greatly appreciated.</p>
