get Mobile Info from all fields in android.os.Build class - Android android.os

Android examples for android.os:Build

Description

get Mobile Info from all fields in android.os.Build class

Demo Code

import java.lang.reflect.Field;

import android.os.Build;

public class Main {

  public static String getMobileInfo() {
    StringBuffer sb = new StringBuffer();

    try {/*from w  ww.  j av  a 2s.  c o m*/

      Field[] fields = Build.class.getDeclaredFields();
      for (Field field : fields) {
        field.setAccessible(true);
        String name = field.getName();
        String value = field.get(null).toString();
        sb.append(name + "=" + value);
        sb.append("\n");
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return sb.toString();
  }

}

Related Tutorials