title: Multiple Loaders with LoaderManager, not getting right Loader
body: <p>I have two loaders, one to populate bind returned data to 2 <code>TextViews</code> and another to populate a <code>ListView</code>. How do I make sure the correct loader loads for each situation? I am getting an error in the where first loader (<code>WR_VIEW</code> case) doesn't seem to be created or loading so in the <code>onLoadFinished()</code> it returns a "No such column found error" because it is accessing the second loader which doesn't call that column.</p>
  
  <p>Here in my <code>onCreate</code> method I set up the adapter for the list view:</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.workouts_options);
  
      String[] uiBindFrom = { ExerciseTable.COLUMN_NAME };
      int[] uiBindTo = { R.id.text1 };
  
      SimpleCursorAdapter adapter = new SimpleCursorAdapter(
          getApplicationContext(), 
          R.layout.exercises_row, 
          null, 
          uiBindFrom, 
          uiBindTo,
          CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);    
  
      final ListView lv = (ListView) findViewById(android.R.id.list);
  
      lv.setAdapter(adapter);
      lv.setEmptyView(findViewById(android.R.id.empty));
      lv.setClickable(true);
      lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int position, long id) {
          }
      });
  
      getSupportLoaderManager().initLoader(WR_VIEW, null, this);
      getSupportLoaderManager().initLoader(EXERCISE_VIEW, null, this);
  }
  </code></pre>
  
  <p>Create my 2 different <code>CursorLoader</code>s:</p>
  
  <pre><code>    public Loader&lt;Cursor&gt; onCreateLoader(int id, Bundle args) {         
          switch(id) {
              case WR_VIEW:
                  String[] projection = { WorkoutRoutineTable.COLUMN_ID, WorkoutRoutineTable.COLUMN_NAME, WorkoutRoutineTable.COLUMN_DESCRIPTION };    
                  return new CursorLoader(this, Workouts.buildWorkoutIdUri(""+mRowId), projection, null, null, null);
              default:
                  String[] columns = {ExercisesColumns.NAME, WRExercisesColumns.COLUMN_ID };          
                  return new CursorLoader(this, Workouts.buildWorkoutIdExerciseUri(""+mRowId), columns, null, null, null);
          }
      }
  </code></pre>
  
  <p>Bind data to my <code>TextViews</code> here and <code>swapCursor</code> for the <code>ListView</code>:</p>
  
  <pre><code>public void onLoadFinished(Loader&lt;Cursor&gt; loader, Cursor cursor) {
      int id = loader.getId();
      switch(id) {
          case WR_VIEW: 
              if (cursor != null &amp;&amp; cursor.moveToFirst()) {
                  mNameText.setText(cursor.getString(cursor.getColumnIndexOrThrow(WorkoutRoutineTable.COLUMN_NAME)));
                  mDescriptionText.setText(cursor.getString(cursor.getColumnIndexOrThrow(WorkoutRoutineTable.COLUMN_DESCRIPTION)));
  
                  getSupportActionBar().setTitle(mNameText.getText());
                  if (!TextUtils.isEmpty(mDescriptionText.getText())) {
                      getSupportActionBar().setSubtitle(mDescriptionText.getText());
                  }
                  cursor.close(); 
              }
          default:
              adapter.swapCursor(cursor);
          }
      }
  </code></pre>
  
  <p>Resetting the Loader:</p>
  
  <pre><code>public void onLoaderReset(Loader&lt;Cursor&gt; loader) {
      int id = loader.getId();
      switch(id) {
          case WR_VIEW: 
              break;
          default:
              adapter.swapCursor(null);
              break;
      }
  }
  </code></pre>