Would like to find out how long the network has been connected for
<p>I am using the following function to get the local IP address of the Android device:</p>

<pre><code>/**
 * Loops through all network interfaces to find one with a connection
 * @return the IP of the connected network device, on error returns null
 */
public String getIPAddress() 
{
    String strIPaddress = null;

    try 
    {
        Enumeration&lt;NetworkInterface&gt; enumNetIF = NetworkInterface.getNetworkInterfaces();
        NetworkInterface netIF = null;

        //loop whilst there are more interfaces
        while(enumNetIF.hasMoreElements()) 
        {
            netIF = enumNetIF.nextElement();

            for (Enumeration&lt;InetAddress&gt; enumIP = netIF.getInetAddresses(); enumIP.hasMoreElements();) 
            {
                InetAddress inetAddress = enumIP.nextElement();

                //check for valid IP, but exclude the loopback address
                if(inetAddress.isLoopbackAddress() != true)
                {
                    strIPaddress = inetAddress.getHostAddress();
                    break;
                }
            }
        }
    } 
    catch (SocketException e) 
    {
        Log.e(TAG, e.getMessage());
    }

    return strIPaddress;
}
</code></pre>

<p>However, I also need to know for how long this IP address has been connected for.
I've searched through the InetAddress structure and couldn't find it:
<a href="http://developer.android.com/reference/java/net/InetAddress.html" rel="nofollow">http://developer.android.com/reference/java/net/InetAddress.html</a></p>

<p>is there another way to find out for how long the local IP address has existed / connected ?</p>
