How to know smallest width (sw) of an android device?

Here is an another easy way .

You can check the Smallest Width of the Device from Developer Options (In Android Studio Emulator & It's not found in my Real Device) .

enter image description here


Best solution for min API 13 and above:

Configuration config = getResources().getConfiguration();
config.smallestScreenWidthDp

The last line return the SW value in dp !

Source google : http://android-developers.blogspot.fr/2011/07/new-tools-for-managing-screen-sizes.html


Correction to the above answer, the right code to find the correct sw try this:

DisplayMetrics dm = getApplicationContext().getResources().getDisplayMetrics();
float screenWidth = dm.widthPixels / dm.density;
float screenHeight = dm.heightPixels / dm.density;

whichever one of screenWidth and screenHeight is smaller is your sw.