Search code examples
androidandroid-contentprovidermaster-detailandroid-cursorloader

When and How to get single value for master item in details activity


I have 2 activities (see picture below).

Activity 1 has ListFragment with list of items filled by CursorLoader. Activity 2 has ActionBar Tabs with ListFragments containing detailed info (also filled by CursorLoader).

Number of tabs I have to read from the first table, it's a item's attribute. What is the best practice to do this? (When? and How?)

When?

  1. OnListItemClick() in the Activity 1 before starting Activity 2
  2. OnCreate() in the Activity 2

If I get this value in OnListItemClick - it will look like slow reaction on user's action, because Activity 2 will be started is onLoaderFinished() after database answer.

My ListFragments implement LoaderManager.LoaderCallbacks. If I get number of tabs in onCreate() - I should implement LoaderManager.LoaderCallbacks also for Activity 2. Wouldn't it bee too overwhelming with Loaders?

HOW?

CursorLoader? Is it a good practice to get one single value with CursorLoader?

Description


Solution

  • As usual, no help, my own answer!

    I've used getContentResolver().query(baseUri, PROJECTION1, null, null, null); in onCreate() of second activity