title: changing cursor of CursorAdapter gives staleDataException
body: <p>okay, so after going through tons of sites and blogs I have finally decided to ask this 'not so FAQ'.</p>
  
  <p>I have 2 listViews. One as the 'category LV' and other as the 'item LV'. The functionality is quite simple- When the user clicks a category cell in the 'category LV', all the items matching that category should filter and appear in the 'item LV'. I do this by assigning the 'category integer' to every item in the database. So, when a category is tapped its integer id is taken and all the ids matching with it in the item database are loaded in the cursor.</p>
  
  <p>PROBLEM:
  I use the adapter.changeCursor(newCursor) method to change the underlying data in the adapter. According to the docs, this method replaces and closes the previously loaded cursor. I am getting this error</p>
  
  <blockquote>
    <p>11-08 11:54:15.939: E/AndroidRuntime(2056): android.database.StaleDataException: Attempting to access a closed CursorWindow.Most probable cause: cursor is deactivated prior to calling this method.</p>
  </blockquote>
  
  <p>Down below is the code explained:</p>
  
  <pre><code>itemAdapter=new CategoryCursorAdapter(this, itemCursor, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER, "item_name",1,date,db);
      categoryLV.setOnItemClickListener(new AdapterView.OnItemClickListener(){
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2,
                  long arg3) {
              // TODO Auto-generated method stub
              String s=((TextView)arg1.findViewById(R.id.category_name)).getText().toString();
  
              if(s.equalsIgnoreCase("all")){
  
                  itemAdapter.changeCursor(null);
                  itemAdapter.notifyDataSetChanged();
              }
  
  
              else{
              itemAdapter.changeCursor(db.getItemCursor(s));
              itemAdapter.notifyDataSetChanged();
  
              }
  
  
  
          }
  
      });
  </code></pre>
  
  <p>I get the error in the CursorAdapter class:</p>
  
  <pre><code>public void bindView(View view, Context context, Cursor cursor) {
      // TODO Auto-generated method stub
      if(mcolumn==CATEGORY_LV){
      TextView tv=(TextView)view.findViewById(R.id.category_name);
          tv.setText(mCursor.getString(mCursor.getColumnIndex(mColumnName)));
          tv.setTextSize(20); 
      }
  
      if(mcolumn==ITEM_LV){
          TextView item=(TextView)view.findViewById(R.id.item_name);
          TextView stock=(TextView)view.findViewById(R.id.stock_status);
  
                     // I get the staleDataException at this place
          String s=mCursor.getString(mCursor.getColumnIndex(mColumnName));
          Button drag=(Button)view.findViewById(R.id.drag_button);
          LinearLayout lv=(LinearLayout)view.findViewById(R.id.layout);
          drag.setFocusable(false);
          item.setText(s);
          item.setTextSize(20);
          stock.setText("Stock:"+mdb.getStockStatus(mdb.getItemCode(s), mDate));
          stock.setTextSize(15);
      }
  }
  </code></pre>
  
  <p>One thing to note here is that I am using the same Adapter class to power both the listViews. However i dont think this can be a problem.</p>