当前位置: 首页>>代码示例>>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;未经允许,请勿转载。