in my app i want to save data at savedInstanceState(). i want to save ArrayList<HashMap<String,String>>. And so far i am unable to do that. 
 here is my code that is bothering me
@Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putParcelableArrayList("places", (ArrayList<? extends Parcelable>) places);
    }
restore() method
private void restore(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        //What should i do here! i have try many things but none of them is helping
    }
                Since ArrayList, HashMap and String are Serializable you can use Bundle.putSerializable and Bundle.getSerializable
@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putSerializable("places", places);
}
private void restore(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        places = (ArrayList<HashMap<String,String>>) savedInstanceState.getSerializable("places"); 
    }
}
Also, make sure you are calling restore from onRestoreInstanceState or onCreate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With