Here you can find the source of getDensity(Context context)
public static float getDensity(Context context)
//package com.java2s; import android.content.Context; public class Main { public static float getDensity(Context context) { float scale = context.getResources().getDisplayMetrics().density; return scale; }/* ww w . j ava 2 s.c om*/ }