get String by resource id - Android android.content

Android examples for android.content:Context

Description

get String by resource id

Demo Code

import android.content.Context;
import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static String getString(Context context, int resourceId) {
        try {/*ww w. j  av  a2  s .co m*/
            String res = context.getResources().getString(resourceId);
            return res;
        } catch (Throwable e) {
        }
        return null;
    }

}

Related Tutorials