title: How to get screen width in dpi?
body: <p>How can I get the screen width dpi?</p>
  <pre><code>DisplayMetrics metrics = getResources().getDisplayMetrics();
  int f = metrics.densityDpi;
  
  
    //  getWindowManager().getDefaultDisplay().getMetrics(metrics);
  
  int width = metrics.widthPixels;
  int dp = (int)(width / (metrics.density));
  </code></pre>
  <p>I do this, so lets assume my densitydpi is 120..and widthpixel 240..
  via calculation i get 240/0.75.... so I have 320 widthdpi?</p>
  <p>However that's not the case....widthdpi is smaller then 320 I think...because 320 goes with me wrong in the screen.... using 120 works.</p>
  <p>on Nexus 4...with width 768 and densitydpi 320...I divide 768/2 and i get 384 correct width density dpi (it works)</p>
  <p>But on other ones like 240, 160, 120 density dpi..the calculation of width dpi seems wrong ...</p>