Android examples for android.content.res:Resources
get Resource Id for name, type and package Name
import android.content.Context; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; public class Main { public static int getResourceId(Context context, String name, String type, String packageName) { Resources themeResources = null; PackageManager pm = context.getPackageManager(); try {/*w ww.j a v a 2 s.c o m*/ themeResources = pm.getResourcesForApplication(packageName); return themeResources.getIdentifier(name, type, packageName); } catch (NameNotFoundException e) { e.printStackTrace(); } return 0; } }