Android examples for java.lang.reflect:Field Static
set Field Final and Static
//package com.java2s; import java.lang.reflect.*; public class Main { public static void setFinalStatic(Field field, Object newValue) throws Exception { field.setAccessible(true);//from w w w . j a va 2 s .c om Field modifiersField = Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); field.set(null, newValue); } }