title: why it gives screen inch size wrong all the time?
body: <p>I want to calculate device size by inch. I am using this code that every search appears. But the problem is when I put device 4.5 inch my answer in android studio is 4. I tried 5.2 inch device and I got 4.3 inch as well 10.1 inch -> the answer is 9.0. <strong>So how can I get accurate answer?</strong></p>
  
  <pre><code> DisplayMetrics dm = new DisplayMetrics();
      getWindowManager().getDefaultDisplay().getMetrics(dm);
  
      double wi=(double)dm.widthPixels/dm.xdpi;
      double hi=(double)dm.heightPixels/dm.ydpi;
      double x = Math.pow(wi,2);
      double y = Math.pow(hi,2);
      double screenInches = Math.sqrt(x+y);
      Log.e("hello"," "+screenInches);
  </code></pre>