Everything in the R
class is a reference, hence it's just defined as an int
.
If your code is running within — or has access to — an Android Context
, you can call context.getString(R.string.my_exception_message)
to get the actual String
value.
Or, for things like exception strings that don't require to be translated and so don't strictly need to be defined in an Android resource .xml file, you could store the strings as constants in some sort of StringConstants
interface. That way you can refer to the strings from within utility classes that may not have access to the Context
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…