0

I am trying to retain my Activity Configuration using

@Override
public Object onRetainNonConfigurationInstance() {
// TODO Auto-generated method stub      
    ArrayList<String> array = new ArrayList<String>();
    array = alarmsArrayList;
    return array;   
}

And when i try

ArrayList<String> data = (ArrayList<String>) getLastNonConfigurationInstance();
    if (data.size() != 0) 
    {
        alarmsArrayList = data;
        alarmList.setAdapter(adapter);
        startProgress(SingleAlarm.this.getCurrentFocus());
    }
    else
    {
        startProgress(SingleAlarm.this.getCurrentFocus());
    }

It gives a Null Pointer Exception.

Is there a way to retain every configuration of the Activity, like the CheckBox status?

LittleBobbyTables - Au Revoir
  • 32,008
  • 25
  • 109
  • 114
Rachit Sachdeva
  • 135
  • 1
  • 1
  • 5

1 Answers1

0

there are plenty of ways to save configuration or states of views in Android. you can read this doc

here is almost a same question asked.

or if you want you can create save views current state in database or shared preferences.

Community
  • 1
  • 1
AAnkit
  • 27,299
  • 12
  • 60
  • 71