user3684678
user3684678

Reputation: 561

Difference between persistent and non-persistent data

onPause() should be used to save persistent data and onSaveInstanceState(Bundle) is typically used to save non-persistent data.What does that mean?What is difference between persistent and non-persistent data?

Upvotes: 6

Views: 21943

Answers (3)

Faisal shahzad
Faisal shahzad

Reputation: 398

Persistence data:
The data which is available after fully closing the application. This type of data must be save into shared preference or database or internal or external memory

Non- persistence data:
The data which is not available after fully closing the application. we can say that non - persistence data mean volatile data that available during the execution of the application.

Upvotes: 10

Alexander Hoffmann
Alexander Hoffmann

Reputation: 6014

Persistent data is data which you want to be available even after you fully close and restart your app.

The three most common ways to safe this data localy is by using SharedPreferences, a local database or the file system (store data as a file).

Android Developers offers a guide for this: http://developer.android.com/training/basics/data-storage/index.html

Upvotes: 7

asadmshah
asadmshah

Reputation: 1368

onPause() should be used to save persistent data

Commit data that is going to be used throughout the life of the application. For example data inside your database or shared preferences.

onSaveInstanceState(Bundle) is typically used to save non-persistent data

Commit data that is specific to the current view session. For example keeping track of the current state of the views on screen.

Upvotes: 1

Related Questions