Skip to content Skip to sidebar Skip to footer

Android - Retrieve The Device-appropriate Drawable Folder As A String

Is it possible to retrieve the correct drawable folder name as a String using Android? For example, I would like, as a string: String drawableFolder = someFunction.getFolder(); Log

Solution 1:

You can get the following through device density

int density= getResources().getDisplayMetrics().densityDpi;

switch(density)
{
case DisplayMetrics.DENSITY_LOW:
    Log.d(TAG, "LDPI");
    break;
case DisplayMetrics.DENSITY_MEDIUM:
     Log.d(TAG, "MDPI");
    break;
case DisplayMetrics.DENSITY_HIGH:
    Log.d(TAG, "HDPI");
    break;
case DisplayMetrics.DENSITY_XHIGH:
     Log.d(TAG, "XHDPI");
    break;
}

Post a Comment for "Android - Retrieve The Device-appropriate Drawable Folder As A String"