This method is used to get a String resources by name - Android App

Android examples for App:Resource

Description

This method is used to get a String resources by name

Demo Code


//package com.java2s;
import android.content.Context;

public class Main {
    /**//ww  w.  j ava2 s. c o  m
     * This method is used to get a String resources by name
     * 
     * @param pContext
     *            application context
     * @param pName
     *            resource name
     * @return
     */
    public static int getStringRessourceByName(final Context pContext,
            final String pName) {
        return pContext.getResources().getIdentifier(pName, "string",
                pContext.getPackageName());
    }
}

Related Tutorials