I have develop an app, in which i have an created a global Activity class which stores all my list and boolean varaiable which can be use in any Activity class and also in non activity class. but when i want to use the getApplication()
in my non activity class it gives me error .
the sample code This is my Application which has all the list and boolean variables to be used
public class MyApplicationData extends Application
{
public String USER_ID = "";
public double user_latitude;
public double user_logitude;
// for password
public boolean remember_password = false;
public ArrayList<Integer>value= new ArrayList<Integer>();
}
I have Another class which is non Activity where i want to use my list to save some data For your reference here is sample code
public class Test
{
public MyApplicationData myApplicationData;
GetApplication getApplicationData ;
@Override
public void characters(char[] ch, int start, int length) throws SAXException
{
super.characters(ch, start, length);
String data = new String(ch,start,length);
if(in_userid)
{
XMLData.user_info_map.put("userid",data);
Log.v("--: PARSED DATA :-- MAP"+i, "userid = "+data);
}
if(in_firstname)
{
XMLData.user_info_map.put("firstname",data);
Log.v("--: PARSED DATA :-- MAP"+i, "firstname = "+data);
}
}
}
I have class which extends Activity
public class GetApplication extends Activity
{
public MyApplicationData getTheApplication()
{
return (MyApplicationData)getApplication();
}
}
I am stuck here can any one help how to store values using Application you help will be highly obliged