title: access the variable in activity in another class
body: <p>In my application I need a variable from one activity to another activity without using any intent. So I have declared that variable as static and used as <code>FirstActivity.a</code> but this is returning so null, Hence I have created a class that extends application and declared that variable there still I am getting null. no clue how to achieve this.</p>
  
  <p>Googled a lot but everyone are suggesting either to use static or extend Application class, unfortunately both are not working for me.</p>
  
  <p>Application class:</p>
  
  <pre><code>public class ApplicationClass extends Application{
  
      private String StockName;
  
      public String getStockName() {
          return StockName;
      }
  
      public void setStockName(String stockName) {
          StockName = stockName;
      }
  
  
  
  }
  </code></pre>
  
  <p>Setting the variable in one activity as:</p>
  
  <pre><code>public class Detail extends Activity{
  
  ApplicationClass ac;
  
   protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.stockdetail);
          ac=new ApplicationClass();
  
          ac.setStockName(getIntent().getExtras().getString("StockName"));
  }
  </code></pre>
  
  <p>Retriving the variable in another class as:</p>
  
  <pre><code>public class Table {
  
      Context c1;
  
      Cursor c;
      ApplicationClass ac=new ApplicationClass();
  
  public String selectdate="Select " + column1 + " as _id, " + column2 + " From " + tablename + " Where " + column3 + " = " 
                                  + ac.getStockName();
  </code></pre>
  
  <p>I'm not sure how to achieve this.</p>
  
  <h2>Edit</h2>
  
  <pre><code>public class Detail extends Activity{
  
  public static sname;
  
   protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.stockdetail);
  
          sname=getIntent().getExtras().getString("StockName");
  }
  
  public class Table {
  
          Context c1;
  
          Cursor c;
  
      public String selectdate="Select " + column1 + " as _id, " + column2 + " From " + tablename + " Where " + column3 + " = " 
                                      + Detail.sname;
  </code></pre>