Why notify listeners in a content provider query method?
- by cbrulak
Vegeolla has this blog post about content providers and the snippet below (at the bottom) with this line:
cursor.setNotificationUri(getContext().getContentResolver(), uri);
I'm curious as to why one would want to notify listeners about a query operation. Am I missing something? 
Thanks
  @Override
  public Cursor query(Uri uri, String[] projection, String selection,
      String[] selectionArgs, String sortOrder) {
    // Uisng SQLiteQueryBuilder instead of query() method
    SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
    // Check if the caller has requested a column which does not exists
    checkColumns(projection);
    // Set the table
    queryBuilder.setTables(TodoTable.TABLE_TODO);
    int uriType = sURIMatcher.match(uri);
    switch (uriType) {
    case TODOS:
      break;
    case TODO_ID:
      // Adding the ID to the original query
      queryBuilder.appendWhere(TodoTable.COLUMN_ID + "="
          + uri.getLastPathSegment());
      break;
    default:
      throw new IllegalArgumentException("Unknown URI: " + uri);
    }
    SQLiteDatabase db = database.getWritableDatabase();
    Cursor cursor = queryBuilder.query(db, projection, selection,
        selectionArgs, null, null, sortOrder);
    // Make sure that potential listeners are getting notified
    cursor.setNotificationUri(getContext().getContentResolver(), uri);
    return cursor;
  }