title: Kotlin set value of global variable
body: <p>We are trying to set the value of a global variable declared in the code below<br/></p>
  
  <pre><code> class MyApplication: Application() {
      var globalVar = 2
  }
  </code></pre>
  
  <p>Now we have a Main Activity that has a Edit Text named etPerson we would like to enter a value in etPerson and set the entered value equal to globalVar<br/>
  Why because we want to make a call to a database function in another Activity<br/>
  Here is the code that makes the call to the DB<br/></p>
  
  <pre><code>    var mApp = MyApplication()
      var intGlobalVar = mApp.globalVar
      println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@ globalINT = "+intGlobalVar)
      var ITEM = db.getItem(intGlobalVar)
      println("%%%%%%%%%%%%%%%%%% ITEM "+ITEM?.id+" name "+ITEM?.name)
  </code></pre>
  
  <p>And for clarity here is the DB function<br/></p>
  
  <pre><code>    fun getItem(id: Int): Contact? {
      val db = this.writableDatabase
      val selectQuery = "SELECT  * FROM $TABLE_NAME WHERE $colId = ?"
      db.rawQuery(selectQuery, arrayOf(id.toString())).use {
          // .use requires API 16
          if (it.moveToFirst()) {
              val result = Contact(0)
              result.id = it.getInt(it.getColumnIndex(colId))
              result.name = it.getString(it.getColumnIndex(colName))
              return result
          }
      }
      return null
  }
  </code></pre>
  
  <p>So the issue is setting the var globalVar to the value entered in etPerson on the Main Activity<br/>
  The concept can be accomplished using put and get with intents but that is not our goal here<br/></p>
  
  <p>Our question is how to set the globalVar to the value entered in the Edit Text?</p>