Code example for LoaderManager

Methods: getLoader, restartLoader

0
 
        loadArtists(); 
    } 
 
    protected void loadArtists() { 
        Loader<Cursor> loader = mLoaderManager.getLoader(ID_ARTIST_LOADER);
 
        Bundle args = new Bundle();
        if (loader != null) {
            mLoaderManager.restartLoader(ID_ARTIST_LOADER, args, mLoaderCallbacks);
        } else { 
            mLoaderManager.initLoader(ID_ARTIST_LOADER, args, mLoaderCallbacks);
        } 
    } 
 
    private static final class ArtistCursorLoader extends CursorLoader {
 
        private static final String[] PROJECTION = new String[] {
            MediaStore.Audio.Artists._ID,
            MediaStore.Audio.Artists.ARTIST,
            MediaStore.Audio.Artists.NUMBER_OF_TRACKS