Get android Ethernet MAC Address (not wifi interface)

I’m using Android with Api level 8 and I want to get the Address of my Ethernet interface (eth0).

On API level 8, the NetworkInterface class don’t have the function getHardwareAddress().
The WifiManager also does not work since this is not an Wireless interface.

  • Android Listview in PopupWindow onitemclick not work on some device
  • BroadcastReceiver not receiving download complete action
  • POST with Android Retrofit
  • MultiDex NoClassDefFound error
  • How to read data from XLS (Excel) file
  • Not able to record call using MediaRecorder
  • Thanks in advance!

    Related posts:

    OnPause and OnStop() called immediately after starting activity
    How to add same view to parent multiple times by inflating it only once
    Travis CI for Android
    Reusing HttpURLConnection so as to keep session alive
    How to dynamically populate Android spinner with text + image
  • Integrating youtube to fragment
  • What is the status of Right To Left languages on Android?
  • How to register some URL namespace (myapp://app.start/) for accessing your program by calling a URL in browser in Android OS?
  • Merging cells in Excel using Apache POI
  • How to suppress Android Lint warning in Gradle script
  • How to use Accelerometer to measure distance for Android Application Development
  • 5 Solutions collect form web for “Get android Ethernet MAC Address (not wifi interface)”

    Assuming your ethernet interface is eth0, try opening and reading the file /sys/class/net/eth0/address.

    This is my solution based on the Joel F answer. Hope it helps someone!

     * Load file content to String
    public static String loadFileAsString(String filePath) throws{
        StringBuffer fileData = new StringBuffer(1000);
        BufferedReader reader = new BufferedReader(new FileReader(filePath));
        char[] buf = new char[1024];
        int numRead=0;
        while(( != -1){
            String readData = String.valueOf(buf, 0, numRead);
        return fileData.toString();
     * Get the STB MacAddress
    public String getMacAddress(){
        try {
            return loadFileAsString("/sys/class/net/eth0/address")
                .toUpperCase().substring(0, 17);
        } catch (IOException e) {
            return null;

    Check also /sys/class/efuse/mac at least on Amlogic platforms.

    Right now (March 2014) Google doesn’t privides an API about Ethernet

    This is the rason because we don’t have a way to get the ethernet mac like in wifi case.

    private String getWifiMACAddress(Context ctx) {
        WifiManager wifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);
        WifiInfo info = wifiManager.getConnectionInfo();
       return info.getMacAddress();

    One alternative is reading the eth0 file. Please let me know if anyone knows otherwise!

    this way to use java fix it; maybe can help you

    NetworkInterface netf = NetworkInterface.getByName("eth0");
    byte[] array = netf.getHardwareAddress();
    StringBuilder stringBuilder = new StringBuilder("");
    String str = "";
    for (int i = 0; i < array.length; i++) {
        int v = array[i] & 0xFF;
        String hv = Integer.toHexString(v).toUpperCase();
        if (hv.length() < 2) {
    str = stringBuilder.substring(0, stringBuilder.length()- 1);
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.