Tasks/src/main/java/com/dummies/tasks/provider/TaskProvider.java
@Override
    public Cursor query(Uri uri, String[] ignored1, String selection,
                        String[] selectionArgs, String sortOrder) {

        String[] projection = new String[]{
                COLUMN_TASKID,
                COLUMN_TITLE,
                COLUMN_NOTES,
                COLUMN_DATE_TIME};

        // Use the UriMatcher to see what kind of query we have and
        // format the db query accordingly
        Cursor c;
        switch (URI_MATCHER.match(uri)) {

            // We were asked to return a list of tasks
            case LIST_TASK:
                c = db.query(DATABASE_TABLE,
                        projection, selection,
                        selectionArgs, null, null, sortOrder);
                break;

            // We were asked to return a specific task
            case ITEM_TASK:
                c = db.query(DATABASE_TABLE, projection,
                        COLUMN_TASKID + "=?",
                        new String[]{Long.toString(ContentUris.parseId
                                (uri))},
                        null, null, null, null);
                if (c.getCount() > 0) {
                    c.moveToFirst();
                }
                break;
            default:
                throw new IllegalArgumentException("Unknown Uri: " + uri);
        }

        // Set the notification URI for this cursor.  Our Loader will
        // use this URI to watch for any changes to our data,
        // and if the data changes the Loader will automatically refresh.
        c.setNotificationUri(getContext().getContentResolver(), uri);
        return c;
    }
/**
     * This method is called when someone wants to read something from
     * our content provider.  We'll turn around and ask our database
     * for the information, and then return it in a Cursor.
     */
This method is called when someone wants to read something from
our content provider.  We'll turn around and ask our database
for the information, and then return it in a Cursor.
This method is called when someone wants to read something from our content provider . We ' ll turn around and ask our database for the information and then return it in a Cursor .
@Override
    public Cursor query(Uri uri, String[] ignored1, String selection,
                        String[] selectionArgs, String sortOrder) {
        String[] projection = new String[]{
                COLUMN_TASKID,
                COLUMN_TITLE,
                COLUMN_NOTES,
                COLUMN_DATE_TIME};
        Cursor c;
        switch (URI_MATCHER.match(uri)) {
            case LIST_TASK:
                c = db.query(DATABASE_TABLE,
                        projection, selection,
                        selectionArgs, null, null, sortOrder);
                break;
            case ITEM_TASK:
                c = db.query(DATABASE_TABLE, projection,
                        COLUMN_TASKID + "=?",
                        new String[]{Long.toString(ContentUris.parseId
                                (uri))},
                        null, null, null, null);
                if (c.getCount() > 0) {
                    c.moveToFirst();
                }
                break;
            default:
                throw new IllegalArgumentException("Unknown Uri: " + uri);
        }
        c.setNotificationUri(getContext().getContentResolver(), uri);
        return c;
    }
@ Override public Cursor query ( Uri uri , String [ ] ignored1 , String selection , String [ ] selectionArgs , String sortOrder ) { String [ ] projection = new String [ ] { COLUMN_TASKID , COLUMN_TITLE , COLUMN_NOTES , COLUMN_DATE_TIME } ; Cursor c ; switch ( URI_MATCHER . match ( uri ) ) { case LIST_TASK : c = db . query ( DATABASE_TABLE , projection , selection , selectionArgs , null , null , sortOrder ) ; break ; case ITEM_TASK : c = db . query ( DATABASE_TABLE , projection , COLUMN_TASKID + "=?" , new String [ ] { Long . toString ( ContentUris . parseId ( uri ) ) } , null , null , null , null ) ; if ( c . getCount ( ) > 0 ) { c . moveToFirst ( ) ; } break ; default : throw new IllegalArgumentException ( "Unknown Uri: " + uri ) ; } c . setNotificationUri ( getContext ( ) . getContentResolver ( ) , uri ) ; return c ; }
This method is called when someone wants to read something from
 our content provider.
This method is called when someone wants to read something from our content provider .
// Use the UriMatcher to see what kind of query we have and // format the db query accordingly // We were asked to return a list of tasks // We were asked to return a specific task // Set the notification URI for this cursor.  Our Loader will // use this URI to watch for any changes to our data, // and if the data changes the Loader will automatically refresh.