Android examples for java.lang.reflect:Field
get Declared Field in current class
//package com.java2s; import java.lang.reflect.Field; public class Main { public static Field getDeclaredField(Object object, String fieldName) { Field field = null;/*from www .j av a 2 s .co m*/ Class<?> clazz = object.getClass(); for (; clazz != Object.class; clazz = clazz.getSuperclass()) { try { field = clazz.getDeclaredField(fieldName); return field; } catch (Exception e) { } } return null; } }