avram / zandy

Zotero on Android
http://www.gimranov.com/avram/w/zandy-user-guide
GNU Affero General Public License v3.0
148 stars 28 forks source link

Data loss on double screen rotation #161

Open davirec opened 2 years ago

davirec commented 2 years ago

Hi, this issue has relation with #160

A data loss problem occurs when data is accidentally deleted or state variables are accidentally assigned with default or initial values. This issue is related to the activity's lifecycle (1). When a screen rotation occurs, the activity is destroyed and resumed. Data loss will happen if the developer does not save the variables before the destruction and restore them after creation. To avoid this, the developers have to implement both the logic necessary to save the activity state in the onSaveInstanceState() callback method and the logic to resume its state in the onRestoreInstanceState() callback method. Another way to avoid data loss problems is to use the view model, designed to store and manage UI-related data in a lifecycle-conscious way (2).

We found failures similar to issue #160 in activities:

Note:

  1. https://developer.android.com/guide/components/activities/activity-lifecycle
  2. https://developer.android.com/topic/libraries/architecture/viewmodel