Does it matter whether I access strings from strings.xml file from different contexts?
I accessed it in many ways such as: getApplicationContext().getString(R.string.name)
, this.getString(R.string.name)
,MainActivity.this.getApplicationContext().getString(R.string.name)
, or simply getString(R.string.name)
.
I understand that the application context lasts the whole application lifetime, but I honestly do not know when I should use it. Also, I cannot understand what is the difference between using this
and MainActivity.this
.
Please explain how I should access strings from both activities and Java classes.