Java tutorial
//package com.java2s; import android.content.Context; import android.content.res.Resources; import java.lang.reflect.Field; public class Main { public static String getStringByName(String name, Context context) { try { Field field = Class.forName("com.poetic.emotion.R$string").getField(name); int drawableRes = field.getInt(field); return context.getString(drawableRes); } catch (Resources.NotFoundException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); } return null; } }