title: Application shows files even after they have been deleted
body: <p>It does not updates automatically, even if a music file has been added or deleted. It shows all the cached files.
  Although I have used Content observer which updates it only when an operation like copying or moving has been done, I want to update the activity as soon as a new file is added or deleted. </p>
  
  <pre><code>public class MusicLoader extends AsyncTaskLoader&lt;List&lt;Music&gt;&gt; {
  
  List&lt;Music&gt; mCache;
  MusicObserver mMusicObserver;
  
  public MusicLoader(Context context) {
      super(context);
  }
  @Override
  public List&lt;Music&gt; loadInBackground() {
  
      final ContentResolver contentResolver = getContext().getContentResolver();
      String path = Environment.getExternalStorageDirectory().getAbsolutePath();
  
      String selection = String.format("%s !=%d AND %s LIKE '%s/Voico/%%'", MediaStore.Audio.Media.IS_MUSIC, 0, MediaStore.Audio.Media.DATA, path);
  
      String [] projections = {MediaStore.Audio.Media._ID,MediaStore.Audio.Media.DATA, MediaStore.Audio.Media.TITLE,MediaStore.Audio.Media.ARTIST, MediaStore.Audio.Media.ALBUM_ID};
  
  
      String sortOrder = MediaStore.Audio.Media.TITLE + " ASC";
      Cursor cr = contentResolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,projections, selection, null, sortOrder);
      List&lt;Music&gt; items = new ArrayList&lt;&gt;();
      if(cr != null &amp;&amp; cr.moveToFirst()) {
          // Cache the column indexes so we don't have to look them up for every iteration of the do-while loop.
          int idIndex = cr.getColumnIndex(MediaStore.Audio.Media._ID);
          int titleIndex = cr.getColumnIndex(MediaStore.Audio.Media.TITLE);
          int artistIndex = cr.getColumnIndex(MediaStore.Audio.Media.ARTIST);
          int albumId =  cr.getColumnIndex(MediaStore.Audio.Media.ALBUM_ID);
          do {
              if(isLoadInBackgroundCanceled()){
                  return items;
              }
              // Music object to hold the music data.
              Music item = new Music();
              // Retrieve the respective music data from the cursor using the column index.
              item.setId(cr.getLong(idIndex));
              item.setTitle(cr.getString(titleIndex));
              item.setArtist(cr.getString(artistIndex));
              item.setAlbumId(cr.getLong(albumId));
              // Once we've loaded the Music object, store it inside of the arraylist.
              items.add(item);
          }
          while(cr.moveToNext());
          cr.close();
  
      }
      return items;
  }
  
  @Override
  public void deliverResult(List&lt;Music&gt; data) {
      if(isReset()){
  
          // CLose cursors or databse handles.
          return;
      }
      // Keep a reference to the loaded music data.
      mCache = data;
  
      // If we are started pass the loaded music to our super implementation that handles sending it to the registered activity/fragment.
      if(isStarted()){
          super.deliverResult(data);
      }
  }
  
  @Override
  protected void onStopLoading() {
      cancelLoad();
  }
  
  @Override
  protected void onStartLoading() {
  
      if(mCache != null) {
          deliverResult(mCache);
  
      }
  
      if(mMusicObserver == null) {
          mMusicObserver = new MusicObserver(this, new Handler());
          getContext().getContentResolver().registerContentObserver(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, true, mMusicObserver);
  
      }
  
  
      if(takeContentChanged() || mCache == null) {
          forceLoad();
  
      }
  
  }
  
  @Override
  protected void onReset() {
      // Close any cursors, web-sockets or database objects
      if(mMusicObserver != null) {
          getContext().getContentResolver().unregisterContentObserver(mMusicObserver);
          mMusicObserver = null;
      }
  }
  
  /**
   * Simple observer that notifies the loader when it has detected a change.
   */
  private  class MusicObserver extends ContentObserver {
  
      private android.support.v4.content.Loader mLoader;
  
      public MusicObserver(android.support.v4.content.Loader loader, Handler handler) {
          super(handler);
          mLoader = loader;
      }
  
      @Override
      public void onChange(boolean selfChange) {
          // A change has been detectec notify the Loader.
  
          mLoader.onContentChanged();
      }
  }
  }
  </code></pre>