Android arp table - developing questions
<p>I've got two problems with the android app I'm writing.</p>

<p>I'm reading out the local arp table from <code>/proc/net/arp</code> and save ip and corresponding mac address in a hash map. See my function. It's working properly.</p>

<pre><code>    /**
     * Extract and save ip and corresponding MAC address from arp table in HashMap
     */
    public Map&lt;String, String&gt; createArpMap() throws IOException {      
        checkMapARP.clear();
        BufferedReader localBufferdReader = new BufferedReader(new FileReader(new File("/proc/net/arp")));
        String line = "";       

        while ((line = localBufferdReader.readLine()) != null) {            
            String[] ipmac = line.split("[ ]+");
            if (!ipmac[0].matches("IP")) {
                String ip = ipmac[0];
                String mac = ipmac[3];
                if (!checkMapARP.containsKey(ip)) {
                    checkMapARP.put(ip, mac);               
                }                   
            }
        }
        return Collections.unmodifiableMap(checkMapARP);
    }
</code></pre>

<ol>
<li><p>First problem:</p>

<p>I'm also using a broadcast receiver. When my app receives the State <code>WifiManager.NETWORK_STATE_CHANGED_ACTION</code> i check if the connection to the gateway is established. If true i call my function to read the arp table. But in this stage the system has not yet builded up the arp table. Sometimes when i receive the connection state the arp table is sill empty.</p>

<p>Anyone got an idea to solve this? </p></li>
<li><p>Second problem:</p>

<p>I want to save the ip and mac address of the gateway in a persistent way. Right now i'm using <a href="http://developer.android.com/guide/topics/data/data-storage.html" rel="nofollow">Shared Preferences</a> for this. Maybe it's better to write to an internal storage?</p>

<p>Any tips?</p></li>
</ol>
