title: Load data from db using content provider
body: <p>I am using content providers to store and retrieve data from Database. This is what happening in the app when user install the app.</p>
  
  <ol>
  <li>App start a service which will download data from server and store
  it in db</li>
  <li>App is using <code>CursorLoader</code> to load data from db</li>
  </ol>
  
  <p>Problem is first time there wouldn't be any data in db until service download the data and store it. When that happens then CursorLoader doesn't load data from db. It does load data from db if i close and reopen the app. </p>
  
  <p>This is how i am using <code>ContentProvider</code></p>
  
  <pre><code>@Override
  public int bulkInsert(Uri uri, ContentValues[] values) {
      final SQLiteDatabase db = feederDbHelper.getWritableDatabase();
      int match = sUriMatcher.match(uri);
      switch (match) {
          case CODE_INSERT_SOURCE:
              //Return the number of rows inserted from our implementation of bulkInsert
              return insertRecords(FeederContract.SourceEntry.TABLE_NAME, db, values, uri);
          case CODE_INSERT_ARTICLE:
              return insertRecords(FeederContract.ArticleEntry.TABLE_NAME, db, values, uri);
          default:
              return super.bulkInsert(uri, values);
      }
  }
  </code></pre>
  
  <p>Here is the <code>insertRecords</code> method</p>
  
  <pre><code>public int insertRecords(String tabbleName, SQLiteDatabase db, ContentValues[] values, Uri uri) {
          db.beginTransaction();
          int rowsInserted = 0;
          try {
              for (ContentValues value : values) {
                  long _id = db.insertWithOnConflict(tabbleName, null, value, SQLiteDatabase.CONFLICT_REPLACE);
                  if (_id != -1) {
                      rowsInserted++;
                  }
              }
              db.setTransactionSuccessful();
          } finally {
              db.endTransaction();
          }
  
          if (rowsInserted &gt; 0) {
              getContext().getContentResolver().notifyChange(uri, null);
          }
          //Return the number of rows inserted from our implementation of bulkInsert
          return rowsInserted;
      }
  </code></pre>
  
  <p>Here is what is happening when user start app first time. I have added comments as well.</p>
  
  <pre><code>@Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.feeds_fragment, container, false);
      ButterKnife.bind(this, view);
      loadAd();
      initRc();
      // Starting service to download feeds
      FeederSyncUtil.startSync(getActivity());
      // Starting loader to load feeds
      getActivity().getSupportLoaderManager().initLoader(ID_FEEDS_LOADER, null, this); 
      return view;
  }
  </code></pre>
  
  <p>these are the loader <code>callbacks</code></p>
  
  <pre><code>@Override
  public Loader&lt;Cursor&gt; onCreateLoader(int id, Bundle args) {
      return new CursorLoader(getActivity(),
              FeederContract.ArticleEntry.CONTENT_URI,
              MAIN_FEED_PROJECTION,
              null,
              null,
              null);
  }
  
  @Override
  public void onLoadFinished(Loader&lt;Cursor&gt; loader, Cursor data) {
      Log.d(TAG, data.getCount() + "");
      mFeedsAdapter.swapCursor(data);
  }
  
  @Override
  public void onLoaderReset(Loader&lt;Cursor&gt; loader) {
      mFeedsAdapter.swapCursor(null);
  }
  </code></pre>
  
  <p>What am i missing here? Even though i am using <code>getContext().getContentResolver().notifyChange(uri, null)</code> but still it doesn't refresh the <code>Cursor</code> Some guidance would be appreciated.</p>