Android examples for java.lang.reflect:Field Value
modify 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{ //w w w.j a v a 2 s. com public static void modifyFieldValue(Object object, String filedName, String filedValue) { Class classType = object.getClass(); Field fild = null; try { fild = classType.getDeclaredField(filedName); fild.setAccessible(true); fild.set(object, filedValue); } catch (NoSuchFieldException ex) { // ExceptionHandler.processFatalException(ex); } catch (Exception ex) { // ExceptionHandler.processFatalException(ex); } } }