Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getLoaderManager in Fragments is deprecated

After update I found that getLoaderManager is deprecated but I can't find that should I use instead of.
How to get LoaderManager? Or what should I use instead of Loaders?

like image 844
Шах Avatar asked Sep 01 '18 12:09

Шах


2 Answers

getLoaderManager has been deprecated, use LoaderManager getInstance instead:

LoaderManager.getInstance(this).initLoader(0, null, this);
like image 150
abhijoseph Avatar answered Nov 10 '22 04:11

abhijoseph


Loaders have been deprecated as of Android P (API 28). The recommended option for dealing with loading data while handling the Activity and Fragment lifecycles is to use a combination of ViewModels and LiveData.ViewModels survive configuration changes like Loaders but with less boilerplate. LiveData provides a lifecycle-aware way of loading data that you can reuse in multiple ViewModels.

like image 43
Fahime Ghasemi Avatar answered Nov 10 '22 05:11

Fahime Ghasemi