Reputation: 325
I am Wanting to preserve data when rotating from horizontal to vertical and back again; I know can be done through xml layouts by creating another layout with the same name using -land extension, (activity_main, activity_main-land).
I have no issues with this.
After rotating my device, the landscape layout comes up as expected. However, the data isn't preserved.
I have been told that hidden methods will automatically preserve the data between rotations as it will look for a landscape layout and if found, will automatically save the data. I was told that if the two layouts are identically named (activity_main, activity_main-land) the program will consider them to be the same activity and so will preserve the data.
Is there something else that I should be doing?
Thank you in advance
Upvotes: 1
Views: 42
Reputation: 12478
hidden methods will automatically preserve the data between rotations
No, they won't. You must save and restore data approprietely.
Please refer Google's guide: Recreating an Activity
Upvotes: 1