Android How to - Get String from Resource by string id








Question

We would like to know how to get String from Resource by string id.

Answer


import android.content.Context;

public class Main {
  public static String getString(Context context,final int mStringId){
    return context.getResources().getString(mStringId);
  }
}