androidloaderandroid-loadermanagerasynctaskloader

What is the appropriate replacement of deprecated getSupportLoaderManager()?


I came to know that getSupportLoaderManager is deprecated. But I want to call:

getSupportLoaderManager().initLoader(0, null, mRecipeLoaderManager);

What should be an alternative to that call? Or can I still use getSupportLoaderManager without worrying?


Solution

  • As stated here: Loaders

    "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."

    Whenever you see something is deprecated, go directly to the developer api reference site and review the class or function for which you're looking and if there is an equivalent alternative.