title: ContentLoader not properly refreshing after database changes
body: <p>I have an SQLiteDatabase whose data is managed by a Content Provider. I'm using a tabbed layout. The first tab has the ability to add rows to the database, whereas the second tab shows items from the database. As I add items to the database from the first tab, the changes <em>should</em> be reflected when I move to the other tab.</p>
  
  <p>Data is being added to the database correctly, and upon first opening of the app, all the current data (and anything new added in a previous version of the app) will appear. However, adding new items to the database is not reflected in the ListFragment.</p>
  
  <pre><code>@Override
      public void onClick(View v) {
          if(v == addSale) {
              Item item = new Item(rn(), null, 100);
              data.add(item);
              total += item.getAmount();
          } else if(v == save) {
              for(Item i: data) {
                  ContentValues cv = new ContentValues();
                  cv.put(DatabaseProvider.COLUMN_COST, i.getAmount());
                  cv.put(DatabaseProvider.COLUMN_ITEM, i.getItem());
                  cv.put(DatabaseProvider.COLUMN_PERSON, i.getPerson());
                  this.getActivity().getContentResolver().insert(DatabaseProvider.CONTENT_URI, cv);
              }
              total = 0;
              data.clear();
          } else if(v == clear) {
              data.clear();
              total = 0;
          }
          items.notifyDataSetChanged();
          totalView.setText(Item.format(total));
      }
  </code></pre>
  
  <p>Here is where I add the items to the database specifically with these lines:</p>
  
  <pre><code>ContentValues cv = new ContentValues();
  cv.put(DatabaseProvider.COLUMN_COST, i.getAmount());
  cv.put(DatabaseProvider.COLUMN_ITEM, i.getItem());
  cv.put(DatabaseProvider.COLUMN_PERSON, i.getPerson());
  this.getActivity().getContentResolver().insert(DatabaseProvider.CONTENT_URI, cv);
  </code></pre>
  
  <p>As I said earlier, items are put into the database correctly, so I'm reasonably sure that this is correct.</p>
  
  <p>Here is the insert method of my DatabaseProvider</p>
  
  <pre><code>@Override
  public Uri insert(Uri uri, ContentValues initialValues) {
      if (sUriMatcher.match(uri) != TABLE) {
          throw new IllegalArgumentException("Invalid URI: " + uri);
      }
  
      if (initialValues == null) {
          initialValues = new ContentValues();
      }
  
      SQLiteDatabase db = dbHelper.getWritableDatabase();
  
      long rowId = db.insert(TABLE_SALES, COLUMN_COST, initialValues);
  
      if (rowId &gt; 0) {
          Uri newUri = ContentUris.withAppendedId(CONTENT_URI, rowId);
          getContext().getContentResolver().notifyChange(uri, null);
          return newUri;
      }
  
      throw new SQLException("Failed to insert row into: " + uri);
  }
  </code></pre>
  
  <p>From the various tutorials and other SO questions, it seems as if</p>
  
  <pre><code>getContext().getContentResolver().notifyChange(uri, null);
  </code></pre>
  
  <p>is the key to getting it to update, and it's there, and is called. But nothing updates.</p>
  
  <p>Finally, my list fragment that display all of the data.</p>
  
  <pre><code>package org.worldsproject.android.barcode;
  
  import org.worldsproject.android.barcode.database.DatabaseProvider;
  
  import android.database.Cursor;
  import android.os.Bundle;
  import android.support.v4.app.LoaderManager;
  import android.support.v4.content.CursorLoader;
  import android.support.v4.content.Loader;
  import android.support.v4.widget.CursorAdapter;
  import android.support.v4.widget.SimpleCursorAdapter;
  
  import com.actionbarsherlock.app.SherlockListFragment;
  
  public class RunningTotal extends SherlockListFragment implements
          LoaderManager.LoaderCallbacks&lt;Cursor&gt; {
      public static final String TAG = "Running Total";
  
      public static final int RUNNING_TOTAL_ID = 1;
      private SimpleCursorAdapter adapter;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          String[] uiBindFrom = { DatabaseProvider.COLUMN_PERSON };
          int[] uiBindTo = { R.id.titled };
  
          adapter = new SimpleCursorAdapter(
                  getActivity().getApplicationContext(), R.layout.list_title,
                  null, uiBindFrom, uiBindTo,
                  CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
  
          setListAdapter(adapter);
          getLoaderManager().initLoader(RUNNING_TOTAL_ID, null, this);
      }
  
      @Override
      public Loader&lt;Cursor&gt; onCreateLoader(int arg0, Bundle arg1) {
          String[] projection = { DatabaseProvider.COLUMN_ID,
                  DatabaseProvider.COLUMN_PERSON};
          return new CursorLoader(getActivity(), DatabaseProvider.CONTENT_URI,
                  projection, null, null, null);
      }
  
      @Override
      public void onLoadFinished(Loader&lt;Cursor&gt; arg0, Cursor cursor) {
          // TODO Auto-generated method stub
          adapter.swapCursor(cursor);
      }
  
      @Override
      public void onLoaderReset(Loader&lt;Cursor&gt; arg0) {
          // TODO Auto-generated method stub
          adapter.swapCursor(null);
      }
  
  }
  </code></pre>
  
  <p>It's nearly a direct clone of <a href="http://mobile.tutsplus.com/tutorials/android/android-sdk_loading-data_cursorloader/" rel="noreferrer">http://mobile.tutsplus.com/tutorials/android/android-sdk_loading-data_cursorloader/</a> and at the moment just displays the name column of each row in the database. It shows previous entries, but as I've said, doesn't update. What step am I missing to get it to update?</p>