Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6626059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:50:56+00:00 2026-05-25T21:50:56+00:00

When identifying Loaders in your LoaderManager, you use unique ids. I’m asking about how

  • 0

When identifying Loaders in your LoaderManager, you use unique ids. I’m asking about how unique those ids have to be.

Does every activity and fragment have its own LoaderManager? Do fragments use the LoaderManager of the Activity they’re attached to? Is there only one LoaderManager that the application owns?

Bonus points if you can tell me how it’s possible to change which LoaderManager you’re using. If I want every fragment in my Activity to use the same LoaderManager (some of them are pulling the same data and sharing Loaders would be nice), is that possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:50:57+00:00Added an answer on May 25, 2026 at 9:50 pm

    I’m currently porting my application to the android compatibility package (mainly for CursorLoader and Fragments). I’m currently trying to share a CursorLoader between two fragments to spare a query to my ContentProvider. Welcome to my world! 😉

    A simple use case:

    − DummyActivity extends FragmentActivity / Log.d(Constants.LOGTAG, “DummyActivity.onCreate ” + getSupportLoaderManager().toString());

    − DataFragment extends Fragment implements LoaderManager.LoaderCallbacks / Log.d(Constants.LOGTAG, “DataFragment.onCreate ” + getLoaderManager().toString());

    − ReportFragment extends Fragment implements LoaderManager.LoaderCallbacks / Log.d(Constants.LOGTAG, “ReportFragment.onCreate ” + getLoaderManager().toString());

    DummyActivity instanciates the DataFragment and the later instanciates the ReportFragment. The logcat output shows differents addresses for each LoaderManager. As a first conclusion, each Fragment seems to have a proper LoaderManager…

    I will continue and update if I can answer to your (our 😉 ) question. If you have made any progress, please share your valuable knowledge.

    Update:

    My assumption is that the loader ids are only associated with a local scope of a LoaderManager for a specific fragment to enable several local loaders to be associated with the fragment (so you can return a different loader in onCreateLoader based on the id int arg and the initLoader calls).

    So far I managed to “reuse” a Loader (… or not):

    − First, I have enabled LoaderManager debugging with getSupportLoaderManager().enableDebugLogging(true); in the DummyActivity onCreate method.

    − Then I have called getActivity().getSupportLoaderManager().initLoader(78, null, this); from the onCreate methods of both DataFragment and ReportFragment.

    − DataFragment exposes the CursorLoader created by the onCreateLoader method via a setter on a mCursorLoader private member.

    − The ReportFragment onCreateLoader returns the DataFragment CursorLoader (after retrieving the Fragment with findFragmentByTag).

    The filtered (and slightly obfuscated) logcat output:

          DummyApp  D  DummyActivity.onCreate
          DummyApp  D  DataFragment.newInstance
          DummyApp  D  ReportFragment.newInstance
          DummyApp  D  DataFragment.onCreate
     LoaderManager  V  initLoader in LoaderManager{405a19d0 in SpecificAction{4059ee98}}: args=null
          DummyApp  D  DataFragment.onCreateLoader
     LoaderManager  V    Created new loader LoaderInfo{405a2298 #78 : CursorLoader{405a22e0}}
          DummyApp  D  DataFragment.onCreate
          DummyApp  D  DataFragment.onActivityCreated
          DummyApp  D  ReportFragment.onCreate
     LoaderManager  V  initLoader in LoaderManager{405a19d0 in DummyActivity{4059ee98}}: args=null
     LoaderManager  V    Re-using existing loader LoaderInfo{405a2298 #78 : CursorLoader{405a22e0}}
          DummyApp  D  SpecificActionReportFragment.onCreate
          DummyApp  D  SpecificActionReportFragment.onActivityCreated
     LoaderManager  V  Starting in LoaderManager{405a19d0 in DummyActivity{4059ee98}}
     LoaderManager  V    Starting: LoaderInfo{405a2298 #78 : CursorLoader{405a22e0}}
     DummyProvider  D  query called
     DummyProvider  D  […]       
     DummyProvider  D  [end of query]
     LoaderManager  V  onLoadComplete: LoaderInfo{405a2298 #78 : CursorLoader{405a22e0}}
     LoaderManager  V    onLoadFinished in CursorLoader{405a22e0 id=78}: CursorWrapperInner{405afb20}
          DummyApp  D  ReportFragment.onLoadFinished
          DummyApp  D  ReportFragment.displayActionReport
          DummyApp  D  DummyActivity.setReportViewsVisibility
          DummyApp  D  ReportFragment.setSaveReportImageViewVisibility
    

    The two fragments are added from the DummyActivity onCreate method (different from the described use case, but that changes nothing to the issue we are working on). Unfortunately, the loader is reassigned to the latest fragment calling it (here ReportFragment)… and DataFragment.onLoadFinished is never called. As a consequence, the ReportFragment looks good but the DataFragment is not up-to-date since the update is called from the onLoadFinished of this class.

    I assume that there is an underlying unregister call then a register call on the CursorLoader.

    To be continued…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone have a query which searches through SQL2005/2008's plan cache identifying queries or
I am trying to figure out under what circumstances I should use weak (non-identifying)
How do you get the unique identifying information from an iPhone/iPad within an app?
I use MD5 hash for identifying files with unknown origin . No attacker here,
I have a very subtle bug that I'm having trouble identifying. Background: We have
Formulate the steps of identifying the median from five unique numbers and visualize them
There are couples of questions around asking for difference / explanation on identifying and
I have a large Excel spreadsheet with a column that has an identifying number.
I have a list of events which has a UUID identifying the browsers. Given
given a string identifying a Django model I have to obtain the associated object

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.