title: Android: How to set R.string value from strings.xml to a global constant in Kotlin?
body: <p>I'm new to Kotlin so maybe I'm missing something obvious, but I couldn't find an answer through Google.</p>
  
  <p>How can I set the value of a Kotlin constant to a strings.xml resource value?  I've tried to do it like below but it's throwing the following error:</p>
  
  <blockquote>
    <p>Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference</p>
  </blockquote>
  
  <p>This is my code, the first val declaration fails:</p>
  
  <pre><code>class MainActivity: AppCompatActivity() {
  
          private val STATUS_PREP = getString(R.string.status_prep) //THIS LINE FAILS
          private val STATUS_FIGHT = "fight" //res.getString(R.string.status_fight)
          private val STATUS_REST = "rest" //res.getString(R.string.status_rest)
          private val STATUS_COMPLETE = "complete" //res.getString(R.string.status_complete)
          private val STATUS_PAUSED = "paused" //res.getString(R.string.status_paused)
  </code></pre>