Is there a difference in using Context.getText and Context.getResources.getText?

So, I noticed that there seem to be two ways to get the same data, and I'm not sure if there are recommendations when you should use them (other than bypassing getResources, memory can be saved if you really don't want to use the object more than once). But apart from this, I would like to know if there are recommendations or reasons to use

Context.getText (id) vs Context.getResources.getText (id)

Can anyone help?

+5
source share
3 answers

There is no difference. The source of getText (id) is:

/**
 * Return a localized, styled CharSequence from the application package's
 * default string table.
 *
 * @param resId Resource id for the CharSequence text
 */
public final CharSequence getText(int resId) {
    return getResources().getText(resId);
}

You can see for yourself Context.java on netmite , which has an Android device version.

+5

, Context.getText(id). Context.getResoures() .

+1

you can see the source code above at grepcode.com

Literally no difference

0
source

All Articles