I have an array list with a list of 100 records which I fetch during the availability of the internet. When the internet is not available then I am fetching it from the Application Class instance. Here is the method how I am doing it :
At the parsing step(when internet is available, after parsing the data) :
BApplication.bAppSession.setFindBData(findBDataList);
Here is the Application Class:
public class BApplication extends Application {
public static BAppSession bAppSession;
@Override
public void onCreate() {
bAppSession = new BAppSession(getApplicationContext());
}
}
Here is my Session Class:
public class BAppSession {
private Context context;
private ArrayList<FindMyBeerData> findMyBeerDataLast = new ArrayList<FindMyBeerData>();
public BeerAppSession(Context context) {
this.context = context;
}
public void setFindMyBeerData(ArrayList<FindMyBeerData> findMyBeerDataList){
this.findMyBeerDataLast = findMyBeerDataList;
}
public ArrayList<FindMyBeerData> getFindMyBeerData(){
return this.findMyBeerDataLast;
}
}
How to Fetch the Data(Offline):
findMyBDataList = BApplication.bAppSession .getFindMyBeerData();
Problem : Everything is working fine, but the problem is when I kill the application from the task manager and restart again (when the internet is not available) , I am getting empty ArrayList. DATA IS LOST WHEN APPLICATION IS KILLED
Query: How to get the data back even if the application is killed by the user ? Suggest me any way to do the same.