Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.util.DisplayMetrics; public class Main { public static float getDensity(Context context) { DisplayMetrics dm = new DisplayMetrics(); dm = context.getApplicationContext().getResources().getDisplayMetrics(); float density = dm.density; return density; } }