Code example for SQLiteQueryBuilder

Methods: appendWherequerysetTables

0
 
    @Override 
    public Cursor query(Uri uri, String[] projection, String selection,
            String[] selectionArgs, String sortOrder) {
 
        SQLiteQueryBuilder qBuilder = new SQLiteQueryBuilder();
        int match = URI_MATCHER.match(uri);
 
        switch (match) {
 
        case SETTINGS:
            qBuilder.setTables(TABLE_NAME);
            break; 
 
        case SETTINGS_ID:
            qBuilder.setTables(TABLE_NAME);
            qBuilder.appendWhere("_id=");
            qBuilder.appendWhere(uri.getPathSegments().get(SETTINGS_ID));
            break; 
 
        default: 
            throw new IllegalArgumentException("Unknown URI: " + uri);
        } 
 
        String orderBy;
        if (TextUtils.isEmpty(sortOrder)) {
            orderBy = Constants.DEFAULT_SORT_ORDER;
        } else { 
            orderBy = sortOrder;
        } 
 
        SQLiteDatabase db = mOpenHelper.getReadableDatabase();
        Cursor ret = qBuilder.query(db, projection, selection, selectionArgs, null, null, orderBy);
 
        if (ret == null) {
            Log.i(TAG, "query failed");
        } else { 
            ret.setNotificationUri(getContext().getContentResolver(), uri);
Experience pair programming with AI  Get Codota for Java