Skip to main content
added 930 characters in body
Source Link
Kiran Kumar
  • 1.2k
  • 9
  • 10

You should define your subclassed application class in your manifest. And you should never call "new ApplicationClass()". You can get a reference to ApplicationClass instance using activity's getApplication() method.

Detail.java:

public class Detail extends Activity{ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.stockdetail); ApplicationClass app = (ApplicationClass)getApplication(); app.setStockName("blah"); } } 

Table.java

public class Table { public String selectDate; public Table(Activity a) { ApplicationClass ac=(ApplicationClass)a.getApplication(); selectdate="Select " + column1 + " as _id, " + column2 + " From " + tablename + " Where " + column3 + " = " + ac.getStockName(); } 

Instantiate Table.java

public NewActivity extends Activity{ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Table t = new Table(this); } } 

You should define your subclassed application class in your manifest. And you should never call "new ApplicationClass()". You can get a reference to ApplicationClass instance using activity's getApplication() method.

You should define your subclassed application class in your manifest. And you should never call "new ApplicationClass()". You can get a reference to ApplicationClass instance using activity's getApplication() method.

Detail.java:

public class Detail extends Activity{ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.stockdetail); ApplicationClass app = (ApplicationClass)getApplication(); app.setStockName("blah"); } } 

Table.java

public class Table { public String selectDate; public Table(Activity a) { ApplicationClass ac=(ApplicationClass)a.getApplication(); selectdate="Select " + column1 + " as _id, " + column2 + " From " + tablename + " Where " + column3 + " = " + ac.getStockName(); } 

Instantiate Table.java

public NewActivity extends Activity{ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Table t = new Table(this); } } 
Source Link
Kiran Kumar
  • 1.2k
  • 9
  • 10

You should define your subclassed application class in your manifest. And you should never call "new ApplicationClass()". You can get a reference to ApplicationClass instance using activity's getApplication() method.