J
J
jestev2016-07-30 18:39:44
Java
jestev, 2016-07-30 18:39:44

How to save data from an array after recreating an activity?

There is an array with images, after re-creating the activity, the array starts working from the very beginning. Is there a way to continue the array (i.e. change pictures) after the activity is recreated?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Zagaevsky, 2016-07-30
@jestev

It is necessary to save all critical data somewhere. For simple ones, SharedPreferences will do. Activities and fragments also have an onSaveInstanceState method - there you can save data in a Bundle, get it in onCreate / onRestoreInstanceState. More important data should be stored in the database, you can use a lot of things - SQLite + StorIO, for example (but this is only for example, there are many options). Images should not be stored in the database, but simply stored in files.

C
coden55, 2016-07-30
@coden55

Move the array to a separate standalone class?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question