Java tutorial
//package com.java2s; import android.util.Log; import java.lang.reflect.Field; public class Main { public static final String TAG = "chicken"; private static Object getField(final Object obj, final String fieldName) { try { Field f = obj.getClass().getField(fieldName); return f.get(obj); } catch (final Exception e) { Log.e(TAG, "Error getting field:", e); } return null; } }