title: How to programmatically change the background color of a button
body: <p>I am using Android Studio and would like to use the colors.xml file to change the background color of a button <code>btn</code>. Both of these work for me:</p>
  
  <pre><code>btn.setBackgroundColor(getResources().getColor(R.color.colorBlue, null));
  </code></pre>
  
  <p>and</p>
  
  <pre><code>btn.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.colorBlue));
  </code></pre>
  
  <p>Which one is better? I guess better means faster and consuming less memory/cpu usage.</p>