How to get "public static final int" value by name?
<p>I created a class to extend KeyEvent:</p>

<pre><code>public class myKeyEvent extends KeyEvent {
    public static final int MY_KEYCODE_01 = KeyEvent.KEYCODE_A;
    //...
    public static final int MY_KEYCODE_30 = KeyEvent.KEYCODE_Z;
}
</code></pre>

<p>Now, i want to get the Integer value by the variable name (eg. "MY_KEYCODE_01" should return integer value KeyEvent.KeyCODE_A) from another class (another file).</p>

<p>I tried to:</p>

<pre><code>try{
    Class cls = myKeyEvent.class.getClass();
    Field field = cls.getDeclaredField("MY_KEYCODE_01");
    int value = (Integer) field.get(cls);
    Log.v("TAG", "Field value is " + value);

} catch (NoSuchFieldException e) {
    Log.e("TAG", "Field either doesn't exist or is not public: " + e.toString() );
}
</code></pre>

<p>In LogCat:</p>

<pre><code>Field either doesn't exist or is not public: java.lang.NoSuchFieldException: MY_KEYCODE_01
</code></pre>

<p>How can I do it?</p>
