get Int Field - Android java.lang.reflect

Android examples for java.lang.reflect:Field

Description

get Int Field

Demo Code


//package com.java2s;

import java.lang.reflect.Field;

public class Main {
    public static int getIntField(Object paramObject, Class paramClass,
            String paramString) {
        try {/*w  ww .ja v a 2s .  c  o  m*/
            Field localField = paramClass.getDeclaredField(paramString);
            localField.setAccessible(true);
            int i = localField.getInt(paramClass);
            return i;
        } catch (IllegalAccessException localIllegalAccessException) {
            return 0;
        } catch (IllegalArgumentException localIllegalArgumentException) {
            return 0;
        } catch (NoSuchFieldException localNoSuchFieldException) {
        }
        return 0;
    }
}

Related Tutorials