Here you can find the singleton class which u can use it across your app as a global variable, i use this usually passing the arraylist
package com.example.testSingleton;
/**
* Created with Sharath yadhav.
* Date: 13/09/2015
* Time: 10:36
*/
public class Singleton {
private static Singleton mInstance = null;
private String mString;
private ArrayList<yourclass> menudeatail;
public ArrayList< yourclass > getMenudeatail() {
return menudeatail;
}
public void setMenudeatail(ArrayList< yourclass > menudeatail) {
this.menudeatail = menudeatail;
}
public static Singleton getInstance(){
if(mInstance == null)
{
mInstance = new Singleton();
}
return mInstance;
}
public String getString(){
return this.mString;
}
public void setString(String value){
mString = value;
}
}
How to use this:
Singleton.getInstance().setMenudeatail(your arraylist);
To retrieve it
Singleton.getInstance().getMenudeatail();
No comments:
Post a Comment