Code example for CursorLoader

Methods: setProjection

    //Called when creating new Loader 
    public Loader<Cursor> onCreateLoader(int id, Bundle args) {
        //Creating CursorLoader that creates the Cursor for the data to be displayed 
        //TODO Make this CL a fully defined one (other constructor) & differentiate between GENRE and SONG 
        CursorLoader cursorLoader = new CursorLoader(this);
        cursorLoader.setProjection(loadSongs ? songData:genreData);
        Log.d(TAG, "Loading new cursor with " + (loadSongs ? songData : genreData));
        return cursorLoader;
    //Called when previous loader finishes 
    public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor data) {
        //Swap in new cursor. Let the framework do its thing 
    //Called when previous loader resets, making data unavailable 
    public void onLoaderReset(Loader<Cursor> loader) {
        //Called when Finished cursor is being closed. Makes sure it is no longer being used.