Android examples for App:Resource
get Resource String by name
//package com.java2s; import android.content.Context; public class Main { public static String getResourceString(String name, Context context) { int nameResourceID = context.getResources().getIdentifier(name, "string", context.getApplicationInfo().packageName); if (nameResourceID == 0) { return ""; //throw new IllegalArgumentException("No resource string found with name " + name); } else {// w w w . j a v a2 s. c o m return context.getString(nameResourceID); } } }