Home » Android » resources – Android – Is getResource() expensive?

resources – Android – Is getResource() expensive?

Posted by: admin May 14, 2020 Leave a comment


if i need to use a resource twice, is it better to store it in a String?

public class Testing extends Activity{
    private String c_stringName;

    public void onCreate(Bundle savedInstanceState)
            c_stringName= this.getString(R.string.name);

How to&Answers:

If you dig down to the machine. The only difference between them is 1 reference.
it may seem like running multiple

c_stringName= this.getString(R.string.name);

is doing alot of work but its is the same and storing it into a string reference.