In my Android activitity, I am using two different arrays. First, I am declaring them, and then in the onCreate() method, I am instantiating them. However, when I populate them and then change the orientation, they are getting instantiated again in the and the data is lost.
public class MainActivity extends Activity {
    private JSONArray first;
    private JSONArray second;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        interestedSections = new JSONArray();
        productsBought = new JSONArray();
    }
        //...
}
I tried to add if (savedInstanceState != null) before initializing the arrays, so as to initialize them for the first time only, however when I change the orientation, they are being null. What can I do in order to persist the data in the arrays throughout the whole application lifecycle please?
 
     
     
    