@Override public void setNotificationUri(ContentResolver cr, Uri uri) { for (Cursor cursor : mCursors) { cursor.setNotificationUri(cr, uri); } }
@Override @Implementation public void setNotificationUri(ContentResolver contentResolver, Uri uri) { wrappedCursor.setNotificationUri(contentResolver, uri); }
@Override public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { SQLiteDatabase db = mOpenHelper.getWritableDatabase(); Cursor cursor = db.query( APODContract.TABLE_NAME, projection, selection, selectionArgs, null /* groupBy */, null /* having */, sortOrder, null /* limit */); cursor.setNotificationUri(getContext().getContentResolver(), APODContract.CONTENT_URI); return cursor; }
final ForceLoadContentObserver observer; public MyCursorLoader(final Context context, ...) { super(context); // ... this.observer = new ForceLoadContentObserver(); } @Override public Cursor loadInBackground() { SQLiteDatabase db = this.dbHelper.getReadableDatabase(); final Cursor c = queryDatabase(db); if (c != null) { // Ensure the cursor window is filled c.getCount(); // this is to force a reload when the content change c.registerContentObserver(this.observer); // this make sure this loader will be notified when // a notifyChange is called on the URI_MY_TABLE c.setNotificationUri(getContext().getContentResolver(), Constants.URI_MY_TABLE); } return c; }
@Override public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { // Get access to underlying database (read-only for query) final SQLiteDatabase db = mTaskDbHelper.getReadableDatabase(); // Write URI match code and set a variable to return a Cursor int match = sUriMatcher.match(uri); Cursor retCursor; // Query for the tasks directory and write a default case switch (match) { // Query for the tasks directory case TASKS: retCursor = db.query(TABLE_NAME, projection, selection, selectionArgs, null, null, sortOrder); break; // Default exception default: throw new UnsupportedOperationException("Unknown uri: " + uri); } // Set a notification URI on the Cursor and return that Cursor retCursor.setNotificationUri(getContext().getContentResolver(), uri); // Return the desired Cursor return retCursor; }
@Override public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { // Get access to underlying database (read-only for query) final SQLiteDatabase db = mTaskDbHelper.getReadableDatabase(); // Write URI match code and set a variable to return a Cursor int match = sUriMatcher.match(uri); Cursor retCursor; // Query for the tasks directory and write a default case switch (match) { // Query for the tasks directory case TASKS: retCursor = db.query(TABLE_NAME, projection, selection, selectionArgs, null, null, sortOrder); break; // Default exception default: throw new UnsupportedOperationException("Unknown uri: " + uri); } // Set a notification URI on the Cursor and return that Cursor retCursor.setNotificationUri(getContext().getContentResolver(), uri); // Return the desired Cursor return retCursor; }
@Override public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { // COMPLETED (1) Get access to underlying database (read-only for query) final SQLiteDatabase db = mTaskDbHelper.getReadableDatabase(); // COMPLETED (2) Write URI match code and set a variable to return a Cursor int match = sUriMatcher.match(uri); Cursor retCursor; // COMPLETED (3) Query for the tasks directory and write a default case switch (match) { // Query for the tasks directory case TASKS: retCursor = db.query(TABLE_NAME, projection, selection, selectionArgs, null, null, sortOrder); break; // Default exception default: throw new UnsupportedOperationException("Unknown uri: " + uri); } // COMPLETED (4) Set a notification URI on the Cursor and return that Cursor retCursor.setNotificationUri(getContext().getContentResolver(), uri); // Return the desired Cursor return retCursor; }
@Override public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { // Get access to underlying database (read-only for query) final SQLiteDatabase db = mTaskDbHelper.getReadableDatabase(); // Write URI match code and set a variable to return a Cursor int match = sUriMatcher.match(uri); Cursor retCursor; // Query for the tasks directory and write a default case switch (match) { // Query for the tasks directory case TASKS: retCursor = db.query(TABLE_NAME, projection, selection, selectionArgs, null, null, sortOrder); break; // Default exception default: throw new UnsupportedOperationException("Unknown uri: " + uri); } // Set a notification URI on the Cursor and return that Cursor retCursor.setNotificationUri(getContext().getContentResolver(), uri); // Return the desired Cursor return retCursor; }
@Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder(); int uriType = sURIMatcher.match(uri); switch (uriType) { case SIMPLEENTITY_DIR: queryBuilder.setTables(TABLENAME); break; case SIMPLEENTITY_ID: queryBuilder.setTables(TABLENAME); queryBuilder.appendWhere(PK + "=" + uri.getLastPathSegment()); break; default: throw new IllegalArgumentException("Unknown URI: " + uri); } Database db = getDatabase(); Cursor cursor = queryBuilder.query(((StandardDatabase) db).getSQLiteDatabase(), projection, selection, selectionArgs, null, null, sortOrder); cursor.setNotificationUri(getContext().getContentResolver(), uri); return cursor; }
@Override public Cursor query(Uri url, String[] projection, String selection, String[] selectionArgs, String sort) { SQLiteQueryBuilder qb=new SQLiteQueryBuilder(); qb.setTables(TABLE); String orderBy; if (TextUtils.isEmpty(sort)) { orderBy=Constants.DEFAULT_SORT_ORDER; } else { orderBy=sort; } Cursor c= qb.query(db.getReadableDatabase(), projection, selection, selectionArgs, null, null, orderBy); c.setNotificationUri(getContext().getContentResolver(), url); return(c); }
@Override public Cursor query(Uri url, String[] projection, String selection, String[] selectionArgs, String sort) { SQLiteQueryBuilder qb=new SQLiteQueryBuilder(); qb.setTables(TABLE); String orderBy; if (TextUtils.isEmpty(sort)) { orderBy=Constants.DEFAULT_SORT_ORDER; } else { orderBy=sort; } Cursor c= qb.query(db.getReadableDatabase(), projection, selection, selectionArgs, null, null, orderBy); c.setNotificationUri(getContext().getContentResolver(), url); return(c); }
cursor.setNotificationUri(getContext().getContentResolver(), uri); return cursor;
cursor.setNotificationUri(getContext().getContentResolver(), uri); return cursor;
cursor.setNotificationUri(getContext().getContentResolver(), uri); return cursor;
cursor.setNotificationUri(getContext().getContentResolver(), uri); return cursor;
cursor.setNotificationUri(getContext().getContentResolver(), uri); return cursor;
cursor.setNotificationUri(getContext().getContentResolver(), uri); return cursor;
cursor.setNotificationUri(contentResolver, notificationUri);
@Override @Nullable public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) { SQLiteDatabase db = databaseHelper.getWritableDatabase(); Cursor cursor = null; switch (matcher.match(uri)) { case TRANSACTIONS: cursor = LocalCupboard.getInstance().withDatabase(db).query(HttpTransaction.class). withProjection(projection). withSelection(selection, selectionArgs). orderBy(sortOrder). getCursor(); break; case TRANSACTION: cursor = LocalCupboard.getInstance().withDatabase(db).query(HttpTransaction.class). byId(ContentUris.parseId(uri)). getCursor(); break; } if (cursor != null) { cursor.setNotificationUri(getContext().getContentResolver(), uri); } return cursor; }
cursor.setNotificationUri(getContext().getContentResolver(), uri);