本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
}