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