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 Loader
s?
Asked
Active
Viewed 6,288 times
12

Denis Sologub
- 7,277
- 11
- 56
- 123
-
2https://developer.android.com/guide/components/loaders – Angus Sep 01 '18 at 13:01
-
1@AngusTay, thank you, I understood the problem in English version. Just Google decided that it's not an important information to show in Russian site version that Loaders are deprecated. – Denis Sologub Sep 01 '18 at 13:07
3 Answers
17
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.

Fahime Ghasemi
- 775
- 9
- 13
6
getLoaderManager has been deprecated, use LoaderManager getInstance instead:
LoaderManager.getInstance(this).initLoader(0, null, this);

abhijoseph
- 307
- 1
- 3
- 5
0
The deprecated getLoaderManager
has been replaced with getSupportLoaderManager
. Try:
getSupportLoaderManager().initLoader(LOADER_NOTES, null, this);
Works for me in API 28.

Egal
- 1,374
- 12
- 22

Shahid Mahmood
- 1
- 1