Java tutorial
//package com.java2s; import android.util.DisplayMetrics; public class Main { public static int getDPI(int size, DisplayMetrics metrics) { return (size * metrics.densityDpi) / DisplayMetrics.DENSITY_DEFAULT; } }