當前位置: 首頁>>代碼示例>>Java>>正文


Java SQLiteQueryBuilder.appendWhere方法代碼示例

本文整理匯總了Java中android.database.sqlite.SQLiteQueryBuilder.appendWhere方法的典型用法代碼示例。如果您正苦於以下問題:Java SQLiteQueryBuilder.appendWhere方法的具體用法?Java SQLiteQueryBuilder.appendWhere怎麽用?Java SQLiteQueryBuilder.appendWhere使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.database.sqlite.SQLiteQueryBuilder的用法示例。


在下文中一共展示了SQLiteQueryBuilder.appendWhere方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:SimpleEntityContentProvider.java

示例2: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Override
public Cursor query(final Uri uri, final String[] projection, final String selection,
                    final String[] selectionArgs, final String sortOrder) {
    final SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
    qb.setTables(DATABASE_TABLE);

    final List<String> pathSegments = uri.getPathSegments();
    if (pathSegments.size() > 2)
        throw new IllegalArgumentException(uri.toString());

    if (pathSegments.size() == 2) {
        final AbstractAddress address = getDepositAddress(uri);
        qb.appendWhere(KEY_DEPOSIT_COIN_ID + "=");
        qb.appendWhereEscapeString(address.getType().getId());
        qb.appendWhere(" AND " + KEY_DEPOSIT_ADDRESS + "=");
        qb.appendWhereEscapeString(address.toString());
    }

    final Cursor cursor = qb.query(helper.getReadableDatabase(), projection,
            selection, selectionArgs, null, null, sortOrder);

    cursor.setNotificationUri(getContext().getContentResolver(), uri);

    return cursor;
}
 
開發者ID:filipnyquist,項目名稱:lbry-android,代碼行數:26,代碼來源:ExchangeHistoryProvider.java

示例3: fetchAll

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
/**
 * Return a Cursor that contains all FailedActionParameter records which matches the parameters.
 * 
 * @param failedActionID
 *          is id of failed action it belongs to, or null to fetch any
 * @param actionParameterName
 *          name of action parameter, or null to fetch any
 * @param failedActionParameterData
 *          is the data associated with this parameter, or null to fetch any
 * @return a Cursor that contains all FailedActionParameter records which matches the parameters.
 */
public Cursor fetchAll(Long failedActionID, String actionParameterName, 
    String failedActionParameterData) {

  SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
  qb.setTables(DATABASE_TABLE);
  qb.appendWhere("1=1");
  if (failedActionID != null) {
    qb.appendWhere(" AND " + KEY_FAILEDACTIONID + " = " + failedActionID);
  }
  if (actionParameterName != null) {
    qb.appendWhere(" AND " + KEY_ACTIONPARAMETERNAME + " = " + actionParameterName);
  }
  if (failedActionParameterData != null) {
    qb.appendWhere(" AND " + KEY_FAILEDACTIONPARAMETERDATA + " = ");
    qb.appendWhereEscapeString(failedActionParameterData);
  }
  // Not using additional selections, selectionArgs, groupBy, having, orderBy, set them to null.
  return qb.query(database, KEYS, null, null, null, null, null);
}
 
開發者ID:biotinker,項目名稱:LibreTasks,代碼行數:31,代碼來源:FailedActionParameterDbAdapter.java

示例4: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Override
public Cursor query(Uri uri, String[] strings, String s, String[] strings1, String s1) {
    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
    switch (sURLMatcher.match(uri)) {
        case TRANSFER_INSTANCE:
            qb.setTables(Constants.TABLE_NAME);
            break;
        case TRANSFER_INSTANCE_ID:
            qb.setTables(Constants.TABLE_NAME);
            qb.appendWhere(Constants.InstanceColumns.ID + "=");
            qb.appendWhere(uri.getLastPathSegment());
            break;
        default:
            throw new IllegalArgumentException("Unknown URL " + uri);
    }
    SQLiteDatabase database = mDbHelper.getReadableDatabase();
    Cursor ret = qb.query(database, strings, s, strings1, null, null, s1);
    if (ret == null) {
        LogUtils.e(TAG, "query error, uri: " + uri);
    } else {
        ret.setNotificationUri(getContext().getContentResolver(), uri);
    }
    return ret;
}
 
開發者ID:lucky-code,項目名稱:Practice,代碼行數:25,代碼來源:WifiDirectContentProvider.java

示例5: findIssuesByStatusAndCreated

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
private Cursor findIssuesByStatusAndCreated(String[] projections, String status, String created) {
    final SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
    queryBuilder.setTables(IssueEntry.TABLE_NAME
            + " INNER JOIN " + ProjectEntry.TABLE_NAME
            + " ON " + IssueEntry.TABLE_NAME + "." + IssueEntry.PROJECT_ID
            + "=" + ProjectEntry.TABLE_NAME + "." + ProjectEntry._ID);
    queryBuilder.appendWhere(IssueEntry.STATUS + " = ? ");
    queryBuilder.appendWhere("AND strftime('%s',"
            + IssueEntry.CREATED_DATE + ") - strftime('%s', ? ) > 0");

    final SQLiteDatabase db = mOpenHelper.getReadableDatabase();

    return queryBuilder.query(
            db,
            projections,
            null,
            new String[]{status, created},
            null,
            null,
            IssueEntry.DEFAULT_SORT,
            null,
            null);
}
 
開發者ID:scarrupt,項目名稱:Capstone-Project,代碼行數:24,代碼來源:BacklogProvider.java

示例6: fetchAll

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
/**
 * Return a Cursor contains all RegisteredActionParameter records which matches the parameters.
 * 
 * @param parameterName
 *          is the parameter name, or null to fetch any parameterName.
 * @param actionID
 *          is the action id, or null to fetch any actionID.
 * @param dataTypeID
 *          is the dataType id, or null to fetch any dataTypeID.
 * @return a Cursor contains all RegisteredActionParameter records which matches the parameters.
 */
public Cursor fetchAll(String parameterName, Long actionID, Long dataTypeID) {
  SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
  qb.setTables(DATABASE_TABLE);
  qb.appendWhere("1=1");
  if (parameterName != null) {
    qb.appendWhere(" AND " + KEY_ACTIONPARAMETERNAME + " = ");
    qb.appendWhereEscapeString(parameterName);
  }
  if (actionID != null) {
    qb.appendWhere(" AND " + KEY_ACTIONID + " = " + actionID);
  }
  if (dataTypeID != null) {
    qb.appendWhere(" AND " + KEY_DATATYPEID + " = " + dataTypeID);
  }
  // Not using additional selections, selectionArgs, groupBy, having, orderBy, set them to null.
  return qb.query(database, KEYS, null, null, null, null, null);
}
 
開發者ID:biotinker,項目名稱:LibreTasks,代碼行數:29,代碼來源:RegisteredActionParameterDbAdapter.java

示例7: fetchAll

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
/**
 * Return a Cursor contains all RegisteredEventAttribute records which matches the parameters.
 * 
 * @param attributeName
 *          is the attribute name, or null to fetch any attributeName
 * @param eventID
 *          is the event id, or null to fetch any eventID
 * @param dataTypeID
 *          is the dataType id, or null to fetch any dataTypeID
 * @return a Cursor contains all RegisteredEventAttribute records which matches the parameters.
 */
public Cursor fetchAll(String attributeName, Long eventID, Long dataTypeID) {
  SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
  qb.setTables(DATABASE_TABLE);
  qb.appendWhere("1=1");
  if (attributeName != null) {
    qb.appendWhere(" AND " + KEY_EVENTATTRIBUTENAME + " = ");
    qb.appendWhereEscapeString(attributeName);
  }
  if (eventID != null) {
    qb.appendWhere(" AND " + KEY_EVENTID + " = " + eventID);
  }
  if (dataTypeID != null) {
    qb.appendWhere(" AND " + KEY_DATATYPEID + " = " + dataTypeID);
  }
  // Not using additional selections, selectionArgs, groupBy, having, orderBy, set them to null.
  return qb.query(database, KEYS, null, null, null, null, null);
}
 
開發者ID:biotinker,項目名稱:LibreTasks,代碼行數:29,代碼來源:RegisteredEventAttributeDbAdapter.java

示例8: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Override
public Cursor query(final Uri uri, final String[] projection, final String selection,
        final String[] selectionArgs, final String sortOrder) {
    final SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
    final int match = sURIMatcher.match(uri);

    switch (match) {
        case SINGLE_PREFERENCE:
        case INTERNAL_SINGLE_PREFERENCE:
            builder.appendWhere(
                    TrayContract.Preferences.Columns.KEY + " = " +
                            DatabaseUtils.sqlEscapeString(uri.getPathSegments().get(2)));
            // no break
        case MODULE_PREFERENCE:
        case INTERNAL_MODULE_PREFERENCE:
            if (match == SINGLE_PREFERENCE
                    || match == INTERNAL_SINGLE_PREFERENCE) {
                builder.appendWhere(" AND ");
            }
            builder.appendWhere(
                    TrayContract.Preferences.Columns.MODULE + " = " +
                            DatabaseUtils.sqlEscapeString(uri.getPathSegments().get(1)));
            // no break
        case ALL_PREFERENCE:
        case INTERNAL_ALL_PREFERENCE:
            builder.setTables(getTable(uri));
            break;
        default:
            throw new IllegalArgumentException("Query is not supported for Uri: " + uri);
    }

    // Query
    Cursor cursor = builder.query(getReadableDatabase(), projection, selection,
            selectionArgs, null, null, sortOrder);

    if (cursor != null) {
        cursor.setNotificationUri(getContext().getContentResolver(), uri);
    }
    return cursor;
}
 
開發者ID:sfilmak,項目名稱:MakiLite,代碼行數:41,代碼來源:TrayProvider.java

示例9: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Override
public Cursor query(Uri uri, String[] projection, String selection,
		String[] selectionArgs, String sortOrder) {
	SQLiteQueryBuilder sqlBuilder = new SQLiteQueryBuilder();
    sqlBuilder.setTables(EVENTS_TABLE);

    if(uriMatcher.match(uri) == 1){
    	sqlBuilder.setProjectionMap(mMap);
    }else if(uriMatcher.match(uri) == 2){
    	sqlBuilder.setProjectionMap(mMap);
    	sqlBuilder.appendWhere(ID + "=?");
    	selectionArgs = DatabaseUtils.appendSelectionArgs(selectionArgs,new String[] {uri.getLastPathSegment()});
    }else if(uriMatcher.match(uri) == 3){
    	sqlBuilder.setProjectionMap(mMap);
    	sqlBuilder.appendWhere(START + ">=? OR ");
    	sqlBuilder.appendWhere(END + "<=?");
    	List<String> list = uri.getPathSegments();
    	String start = list.get(1);
    	String end = list.get(2);
    	selectionArgs = DatabaseUtils.appendSelectionArgs(selectionArgs,new String[] {start,end});
    }
    if(sortOrder == null || sortOrder == "")
    	sortOrder = START + " COLLATE LOCALIZED ASC";
	Cursor c = sqlBuilder.query(db, projection, selection, selectionArgs,null,null, sortOrder);
	c.setNotificationUri(getContext().getContentResolver(), uri);
	return c;
}
 
開發者ID:ur13l,項目名稱:Guanajoven,代碼行數:28,代碼來源:CalendarProvider.java

示例10: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Nullable
@Override
public Cursor query(
        Uri uri, String[] projection, String selection,
        String[] selectionArgs, String sortOrder
) {
    SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
    queryBuilder.setTables(FeedContract.Feeds.TABLE_NAME);

    int uriType = sURIMatcher.match(uri);
    switch (uriType) {

        case FEEDS:
            break;

        case FEED_ID:
            queryBuilder.appendWhere(
                    FeedContract.Feeds._ID + "=" + uri.getLastPathSegment()
            );
            break;

        default:
            throw new IllegalArgumentException("Unknown URI: " + uri);
    }

    SQLiteDatabase db = _database.getWritableDatabase();
    Cursor cursor = queryBuilder.query(
            db, projection, selection, selectionArgs, null, null, sortOrder
    );
    cursor.setNotificationUri(getContext().getContentResolver(), uri);

    return cursor;
}
 
開發者ID:no-go,項目名稱:AnotherRSS,代碼行數:34,代碼來源:FeedContentProvider.java

示例11: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Nullable
@Override
public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs,
                    String sortOrder) {
    final SQLiteDatabase db = mOpenHelper.getReadableDatabase();
    MovieUriEnum matchingUriEnum = mUriMatcher.matchUri(uri);

    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
    qb.setTables(matchingUriEnum.table);
    switch (matchingUriEnum) {
        case MOVIES_ID:
            qb.appendWhere(MoviesColumns.MOVIE_ID + "=" + Movies.getMovieId(uri));
            break;
        case TVS_ID:
            qb.appendWhere(TVsColumns.TV_ID + "=" + TVs.getTVId(uri));
            break;
        case PERSONS_ID:
            qb.appendWhere(PersonsColumns.PERSON_ID + "=" + Persons.getPersonId(uri));
            break;
    }

    Cursor cursor = db.query(matchingUriEnum.table,
            projection,
            selection,
            selectionArgs,
            null,
            null,
            sortOrder);

    if (getContext() != null) {
        cursor.setNotificationUri(getContext().getContentResolver(), uri);
    }

    return cursor;
}
 
開發者ID:qqq3,項目名稱:inventum,代碼行數:36,代碼來源:MovieProvider.java

示例12: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
        String sortOrder) {
    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();

    switch (sUriMatcher.match(uri)) {
    case ITEMS:
        qb.setTables(TABLE_NAME);
        qb.setProjectionMap(sProjectionMap);
        break;

    case ITEM_ID:
        qb.setTables(TABLE_NAME);
        qb.setProjectionMap(sProjectionMap);
        qb.appendWhere(ShoppingList._ID + "=" + uri.getPathSegments().get(1));
        break;

    default:
        throw new IllegalArgumentException("Unknown URI " + uri);
    }

    // If no sort order is specified use the default
    String orderBy;
    if (TextUtils.isEmpty(sortOrder)) {
        orderBy = ShoppingList.DEFAULT_SORT_ORDER;
    } else {
        orderBy = sortOrder;
    }

    // Get the database and run the query
    SQLiteDatabase db = mOpenHelper.getReadableDatabase();
    Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy);

    // Tell the cursor what uri to watch, so it knows when its source data changes
    c.setNotificationUri(getContext().getContentResolver(), uri);
    return c;
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:38,代碼來源:TrollyProvider.java

示例13: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
        String sortOrder) {
    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
    qb.setTables(NOTES_TABLE_NAME);

    switch (sUriMatcher.match(uri)) {
    case NOTES:
        qb.setProjectionMap(sNotesProjectionMap);
        break;

    case NOTE_ID:
        qb.setProjectionMap(sNotesProjectionMap);
        qb.appendWhere(NoteColumns._ID + "=" + uri.getPathSegments().get(1));
        break;

    case LIVE_FOLDER_NOTES:
        qb.setProjectionMap(sLiveFolderProjectionMap);
        break;

    default:
        throw new IllegalArgumentException("Unknown URI " + uri);
    }

    // If no sort order is specified use the default
    String orderBy;
    if (TextUtils.isEmpty(sortOrder)) {
        orderBy = NoteColumns.DEFAULT_SORT_ORDER;
    } else {
        orderBy = sortOrder;
    }

    // Get the database and run the query
    SQLiteDatabase db = mOpenHelper.getReadableDatabase();
    Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy);

    // Tell the cursor what uri to watch, so it knows when its source data changes
    c.setNotificationUri(getContext().getContentResolver(), uri);
    return c;
}
 
開發者ID:firebase,項目名稱:firebase-testlab-instr-lib,代碼行數:41,代碼來源:NotePadProvider.java

示例14: appendAddresses

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
private static void appendAddresses(final SQLiteQueryBuilder qb, final String[] addresses) {
    for (final String address : addresses) {
        qb.appendWhereEscapeString(address.trim());
        if (!address.equals(addresses[addresses.length - 1]))
            qb.appendWhere(",");
    }
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:8,代碼來源:AddressBookProvider.java

示例15: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Override
    public Cursor query(Uri url, String[] projectionIn, String selection,
                        String[] selectionArgs, String sort) {
        SQLiteQueryBuilder qb = new SQLiteQueryBuilder();

        // Generate the body of the query
        int match = sURLMatcher.match(url);
        switch (match) {
            case DATA:
                qb.setTables("data");
                break;
            case DATA_ID:
                qb.setTables("data");
                qb.appendWhere("_id=");
                qb.appendWhere(url.getPathSegments().get(1));
                break;
            default:
                throw new IllegalArgumentException("Unknown URL " + url);
        }

        SQLiteDatabase db = mOpenHelper.getReadableDatabase();
        Cursor ret = qb.query(db, projectionIn, selection, selectionArgs,
                null, null, sort);

        if (ret == null) {
            if (false) Log.d(TAG, "Alarms.query: failed");
        } else {
//            ret.setNotificationUri(getContext().getContentResolver(), url);
        }

        return ret;
    }
 
開發者ID:blackarbiter,項目名稱:Android_Code_Arbiter,代碼行數:33,代碼來源:LocalProvider.java


注:本文中的android.database.sqlite.SQLiteQueryBuilder.appendWhere方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。