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


Java DatabaseUtils.appendSelectionArgs方法代碼示例

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


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

示例1: query

import android.database.DatabaseUtils; //導入方法依賴的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

示例2: addIdToSelectionArgs

import android.database.DatabaseUtils; //導入方法依賴的package包/類
protected static String[] addIdToSelectionArgs(int match, Uri uri, String[] selectionArgs) {
    String[] whereArgs;
    switch (match) {
        case MATCH_PHOTO_ID:
        case MATCH_ALBUM_ID:
        case MATCH_METADATA_ID:
            whereArgs = new String[] {
                uri.getPathSegments().get(1),
            };
            break;
        default:
            return selectionArgs;
    }
    return DatabaseUtils.appendSelectionArgs(selectionArgs, whereArgs);
}
 
開發者ID:asm-products,項目名稱:nexus-gallery,代碼行數:16,代碼來源:PhotoProvider.java

示例3: addMetadataKeysToSelectionArgs

import android.database.DatabaseUtils; //導入方法依賴的package包/類
protected static String[] addMetadataKeysToSelectionArgs(String[] selectionArgs, Uri uri) {
    List<String> segments = uri.getPathSegments();
    String[] additionalArgs = {
            segments.get(1),
            segments.get(2),
    };

    return DatabaseUtils.appendSelectionArgs(selectionArgs, additionalArgs);
}
 
開發者ID:asm-products,項目名稱:nexus-gallery,代碼行數:10,代碼來源:PhotoProvider.java

示例4: query

import android.database.DatabaseUtils; //導入方法依賴的package包/類
/**
 * Handle incoming queries.
 */
@Override
public Cursor query(Uri uri, String[] projection, String selection,
        String[] selectionArgs, String sortOrder) {

    // Constructs a new query builder and sets its table name
    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
    qb.setTables(MainTable.TABLE_NAME);

    switch (mUriMatcher.match(uri)) {
        case MAIN:
            // If the incoming URI is for main table.
            qb.setProjectionMap(mNotesProjectionMap);
            break;

        case MAIN_ID:
            // The incoming URI is for a single row.
            qb.setProjectionMap(mNotesProjectionMap);
            qb.appendWhere(MainTable._ID + "=?");
            selectionArgs = DatabaseUtils.appendSelectionArgs(selectionArgs,
                    new String[] { uri.getLastPathSegment() });
            break;

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


    if (TextUtils.isEmpty(sortOrder)) {
        sortOrder = MainTable.DEFAULT_SORT_ORDER;
    }

    SQLiteDatabase db = mOpenHelper.getReadableDatabase();

    Cursor c = qb.query(db, projection, selection, selectionArgs,
            null /* no group */, null /* no filter */, sortOrder);

    c.setNotificationUri(getContext().getContentResolver(), uri);
    return c;
}
 
開發者ID:luoqii,項目名稱:ApkLauncher,代碼行數:43,代碼來源:LoaderThrottle.java

示例5: query

import android.database.DatabaseUtils; //導入方法依賴的package包/類
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    int uriMatch = uriMatcher.match(uri);
    switch (uriMatch) {
        case ROUTE_PLANETS:
            return db.query(PlanetContract.Planet.TABLE_NAME, projection, selection, selectionArgs, null, null, sortOrder);
        case ROUTE_PLANET:
            long id = PlanetContract.Planet.idFromUri(uri);
            selection = DatabaseUtils.concatenateWhere(selection, String.format("%s=?", PlanetContract.Planet._ID));
            selectionArgs = DatabaseUtils.appendSelectionArgs(selectionArgs, new String[]{Long.toString(id)});
            return db.query(PlanetContract.Planet.TABLE_NAME, projection, selection, selectionArgs, null, null, sortOrder);
        default:
            throw new UnsupportedOperationException("Unknown uri: " + uri);
    }
}
 
開發者ID:atomicrobot,項目名稱:vinyl,代碼行數:16,代碼來源:PlanetContentProvider.java


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