Here you can find the source of getStringResourceByName(String aString, Context context)
public static int getStringResourceByName(String aString, Context context)
//package com.java2s; import android.content.Context; public class Main { public static int getStringResourceByName(String aString, Context context) {//from w ww . jav a2s. co m String packageName = context.getPackageName(); int resId = context.getResources().getIdentifier(aString, "string", packageName); return resId; } }