Code example for LoaderManager

Methods: destroyLoader, initLoader

0
        this.dataUpdatedListener = dataUpdatedListener;
    } 
 
    public void initLoader() { 
        destroyLoader(); 
        loaderManager.initLoader(LOADER_ID, null, this);
    } 
 
    public void destroyLoader() { 
        loaderManager.destroyLoader(LOADER_ID);
 
    } 
 
    @Override 
    public Loader<Cursor> onCreateLoader(int id, Bundle args) {
        return postReader.getAll(context);
    } 
 
    @Override 
    public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
        imageModels = postReader.populateListWith(data);