I
I
Ilya2018-04-17 16:50:50
Java
Ilya, 2018-04-17 16:50:50

How to add an array of objects to sharedPreferences?

I have an array that consists of films - instances of the FilmItem class :

private ArrayList<FilmItem> filmItems = new ArrayList<>();

How to save it through sharedPreferences and then read it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
illuzor, 2018-04-17
@sidorchik

No way.
You can write your own implementation of converting your list to a string and back.
But SharedPreferences is not designed to store large amounts of data, use a database.

D
Dmtm, 2018-04-19
@Dmtm

serialization to json (so as not to write the converter yourself), store as a string

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question