Search code examples
androidlistviewdatepickerlandscapeportrait

Saving the list data on screen orientation in Android


I have one datepicker and one search button. On search button click, I have to pass the selected date to backend and display the fetched data in listview below search button.

In portrait mode I am able to display the data listview after clicking on search button. But when I rotate the emulator all the data getting lost.

How can I preserve the searched data to display in listview in landscape mode.

Please help me. Share some example code if possible.


Solution

  • android:configChanges="orientation|screenSize"
    

    add this line inside your activity in manifest file. then data will not lose during orientation change