There are two ways by this u can accomplish your task.
1> By overriding Onpause() and OnResume methods of activity lifecycle.
2> By using Shared preferences also u can do this.
Now it depends on what u want to preserve ie. data in listview or arraylist etc.
if u are using listview and arraylist u can accomplish by following code
u can create class..
public class ResultsAdapter extends ArrayAdapter implements Filterable{
private ArrayList subItems;
private ArrayList allItems;// = new ArrayList();
private LayoutInflater inflater;
private PTypeFilter filter;
private OnCheckedChangeListener test;
public ResultsAdapter(Context context, int textViewResourceId, ArrayList items,OnCheckedChangeListener a) {
super(context, textViewResourceId, items);
//this.subItems = items;
for( int i = 0;i < items.size();i++){
subItems.add(items.get(i));
}
this.allItems = this.subItems;
inflater= LayoutInflater.from(context);
test =a;
}
Now on Oncreate add this
ListView lvr = (ListView)findViewById(R.id.search_results);
this.m_adapter = new ResultsAdapter(home.this, R.layout.listrow,
sResultsArr,home.this);
this.specsAdapter = new FeaturesExpandableAdapter(home.this,new ArrayList<String>
(),new ArrayList<ArrayList<Feature>>());
lvr.setAdapter(this.m_adapter);
Is this answer you question
Thanks Rakesh