How can I get netmask from Android device?

Try this.

WifiManager wifiMgr = (WifiManager) getContext().getSystemService(context.WIFI_SERVICE);

   DhcpInfo dhcpInfo = wifiMgr.getDhcpInfo();
 String  s_netmask = String.valueOf(dhcpInfo.netmask);
String   s_ipAddress = String.valueOf(dhcpInfo.ipAddress);
   //use formatter for showing correct ip sequence, firstly convert
  // string into integer beacause formatter take integer.
   String snetamsk = Formatter.formatIpAddress(netamsk);
   String sipadress = Formatter.formatIpAddress(ipadress);
Add Following Permission in your Manifest.