There is a method:
public String formatString(String str, int resId) { return String.format("%s %s", context.getResources().getString(resId), str); } How to make it check for him (using try / catch ) so that int resId does not equal 0, namely if it suddenly equaled 0, then the action would not be performed.