get Int File Value From Class - Android java.lang.reflect

Android examples for java.lang.reflect:Field Value

Description

get Int File Value From Class

Demo Code


//package com.java2s;

import java.lang.reflect.Field;

public class Main {

    public static int getIntFileValueFromClass(Class c, String filedName) {
        Field fild = null;/*from   w  ww. j a v  a 2  s . co  m*/
        int fildValue = 0;
        try {
            fild = c.getDeclaredField(filedName);
            fild.setAccessible(true);
            fildValue = fild.getInt(c);

        } catch (NoSuchFieldException ex) {
        } catch (Exception ex) {
        }
        return fildValue;
    }
}

Related Tutorials