Java tutorial
//package com.java2s; //License from project: Apache License import android.util.DisplayMetrics; public class Main { private static String UNKNOWN = ""; /** * The screen density expressed as dots-per-inch. * @param density_dpi "densityDpi" */ public static String getDensityDPIStr(int density_dpi) { switch (density_dpi) { case DisplayMetrics.DENSITY_LOW://120 return "DENSITY_LOW"; case DisplayMetrics.DENSITY_MEDIUM://160 return "DENSITY_MEDIUM/DENSITY_DEFAULT"; //case DisplayMetrics.DENSITY_DEFAULT://160 // return "DENSITY_DEFAULT"; case DisplayMetrics.DENSITY_TV://213 return "DENSITY_TV"; case DisplayMetrics.DENSITY_HIGH://240 return "DENSITY_HIGH"; case DisplayMetrics.DENSITY_280://280 return "DENSITY_280"; case DisplayMetrics.DENSITY_XHIGH://320 return "DENSITY_XHIGH"; case DisplayMetrics.DENSITY_360://360 return "DENSITY_360"; case DisplayMetrics.DENSITY_400://400 return "DENSITY_400"; case DisplayMetrics.DENSITY_420://420 return "DENSITY_420"; case DisplayMetrics.DENSITY_XXHIGH://480 return "DENSITY_XXHDPI"; case DisplayMetrics.DENSITY_560://560 return "DENSITY_560"; case DisplayMetrics.DENSITY_XXXHIGH://640 return "DENSITY_XXXHDPI"; default: return UNKNOWN; } } }