本文整理匯總了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);
}
}