L
L
loly2016-05-22 16:33:49
Java
loly, 2016-05-22 16:33:49

How adequate is the replacement of "intent.putExtra" with sharedPreferences?

A requirement in one of the applications being developed is the use of MVP, where

  • Model - get and store data
  • View - 1 activity and many fragments
  • Presenter - application logic, each fragment has its own presenter (it is also an intermediary between View and Model)

Однако я не понимаю как реализовать передачу данных между фрагментами, кроме как создавать в каждом презентере по модели, данные в которой будут храниться и подтягиваться из sharedPreferences и им подобных.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Денис Загаевский, 2016-05-22
@loly

No, it will not. I didn’t understand what your problem is, but it’s better to transfer data to the fragment through the Bundle using the set / getArguments () methods of the fragment. In the place where you create the fragment, you set arguments for it, in the life cycle methods (like onCreate) - take them. You can also use the FragmentArgs library, it simplifies this process.
Links:
https://developer.android.com/reference/android/ap...
https://github.com/sockeqwe/fragmentargs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question