1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| @Override public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
final SQLiteDatabase db = mTaskDbHelper.getReadableDatabase();
int match = sUriMatcher.match(uri); Cursor retCursor;
switch (match) { case TASKS: retCursor = db.query(TABLE_NAME, projection, selection, selectionArgs, null, null, sortOrder); break;
case TASK_WITH_ID: String id = uri.getPathSegments().get(1);
String mSelection = "_id=?"; String[] mSelectionArgs = new String[]{id};
retCursor = db.query(TABLE_NAME, projection, mSelection, mSelectionArgs, null, null, sortOrder); break;
default: throw new UnsupportedOperationException("Unknown uri: " + uri); }
retCursor.setNotificationUri(getContext().getContentResolver(), uri);
return retCursor; }
|