title: How to pass data from activity to a class?
body: <p>How can i send data from an activity to a class ? </p>
  
  <p>I tried to pass a String using getter but this gives me the initial value of the variable , but my String's value changes in my onCreate. Any ideas how can i pass it to my class ? </p>
  
  <p>Here is some code : </p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
   private String global ; 
      public String getGlobal() {
      return global;
  }
   ...
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState); 
      ...
     listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              global = String.valueOf(parent.getItemAtPosition(position));
  
          }
      });
  }
  </code></pre>
  
  <p>And here is my class</p>
  
  <pre><code>public class SimpleVar {
  MainActivity mainActivity = new MainActivity() ;
  String data = mainActivity.getGlobal; }
  </code></pre>
  
  <p>Any help will be much appreciated. Thank you in advance !</p>