Android examples for java.lang.reflect:Field Value
get Field Value via reflection
import java.lang.reflect.Field; import java.lang.reflect.Method; import android.util.Log; public class Main{ private static final String TAG = ""; public static Object getFieldValue(Class<?> fieldClass, String fieldName, Object instance) { try {/*from w ww .ja v a 2s . c om*/ final Field field = fieldClass.getDeclaredField(fieldName); field.setAccessible(true); return field.get(instance); } catch (Exception e) { Log.w(TAG, Log.getStackTraceString(e)); } return null; } }