Android examples for java.lang.reflect:Field Value
get Static Field Value
import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class Main{ public static Object getStaticFieldValue(Class cls, String fieldName) { Field fild = null;//w ww . j av a 2 s . c o m Object fildValue = null; try { fild = cls.getDeclaredField(fieldName); fild.setAccessible(true); fildValue = fild.get(null); } catch (NoSuchFieldException ex) { ExceptionHandler.processFatalException(ex); } catch (Exception ex) { ExceptionHandler.processFatalException(ex); } return fildValue; } }