title: How do I get IP_ADDRESS in IPV4 format
body: <p>I am trying to get the IP address of an device i.e using WIFI or 3G connection. I am getting the ip address in IPV6 format which is not understandable. I want in IPV4 format IP address.I have done google but dint found any proper solutions.</p>
  
  <p>here is code which I am using to get IP address of an device</p>
  
  <pre><code>public String getLocalIpAddress() {
      try {
          try {
          for (Enumeration&lt;NetworkInterface&gt; en = NetworkInterface
                  .getNetworkInterfaces(); en.hasMoreElements();) {
              NetworkInterface intf = en.nextElement();
              for (Enumeration&lt;InetAddress&gt; enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) 
              {
                  InetAddress inetAddress = enumIpAddr.nextElement();
                  System.out.println("ip1--:" + inetAddress);
                  System.out.println("ip2--:" + inetAddress.getHostAddress());
                  if (!inetAddress.isLoopbackAddress()) {
  
  
                      String ip = inetAddress.getHostAddress().toString();
                      System.out.println("ip---::" + ip);
                      EditText tv = (EditText) findViewById(R.id.ipadd);
                      tv.setText(ip);
                      return inetAddress.getHostAddress().toString();
  
                  }
              }
          }
      } catch (Exception ex) {
          Log.e("IP Address", ex.toString());
      }
      return null;
  }
  </code></pre>
  
  <p>I am getting this ouput :</p>
  
  <pre><code>ip1--:/fe80::5054:ff:fe12:3456%eth0%2
  ip2--:fe80::5054:ff:fe12:3456%eth0
  </code></pre>
  
  <p>It should be displayed like this :</p>
  
  <pre><code>192.168.1.1
  </code></pre>
  
  <p>please help me out..</p>