Code example for SQLiteQueryBuilder

Methods: appendWherequerysetProjectionMapsetTables

0
    @Override 
    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
        if (Binder.getCallingPid() != android.os.Process.myPid()) {
            throw new SecurityException("Cannot read from this provider");
        } 
        SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
        switch (URI_MATCHER.match(uri)) {
            case SYMMETRIC_KEY:
                qb.setTables(TABLE_SYMMETRIC_KEYS);
                qb.setProjectionMap(sSymmetricKeyProjectionMap);
                break; 
            case SYMMETRIC_KEY_ID:
                qb.setTables(TABLE_SYMMETRIC_KEYS);
                qb.setProjectionMap(sSymmetricKeyProjectionMap);
                qb.appendWhere(SymmetricKeyStoreColumns._ID + "=" + uri.getPathSegments().get(1));
                break; 
            case ECDH_KEY:
                qb.setTables(TABLE_ECDH_KEYS);
                qb.setProjectionMap(sECDHKeyProjectionMap);
                break; 
            case ECDH_KEY_ID:
                qb.setTables(TABLE_ECDH_KEYS);
                qb.setProjectionMap(sECDHKeyProjectionMap);
                qb.appendWhere(ECDHKeyStoreColumns._ID + "=" + uri.getPathSegments().get(1));
                break; 
            default: 
                throw new IllegalArgumentException("Unknown URI " + uri);
        } 
        SQLiteDatabase db = mOpenHelper.getReadableDatabase();
        Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, sortOrder);
        c.setNotificationUri(getContext().getContentResolver(), uri);
        return c;
    } 
 
    @Override 
Contextual code suggestions in your IDE  Get Codota for Java