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