Android examples for java.lang.reflect:Field
get Declared Field
//package com.java2s; import java.lang.reflect.Field; import android.util.Log; public class Main { public static Field getDeclaredField(Object object, String fieldName) { Field field = null;//from ww w .j a v a2 s .co m Class<?> clazz = object.getClass(); while (clazz != Object.class) { try { field = clazz.getDeclaredField(fieldName); return field; } catch (Exception e) { Log.i("ReflectUtil File", ""); clazz = clazz.getSuperclass(); } } return null; } }