本文整理汇总了Java中net.sqlcipher.database.SQLiteQueryBuilder.query方法的典型用法代码示例。如果您正苦于以下问题:Java SQLiteQueryBuilder.query方法的具体用法?Java SQLiteQueryBuilder.query怎么用?Java SQLiteQueryBuilder.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sqlcipher.database.SQLiteQueryBuilder
的用法示例。
在下文中一共展示了SQLiteQueryBuilder.query方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContactId
import net.sqlcipher.database.SQLiteQueryBuilder; //导入方法依赖的package包/类
private long getContactId(final SQLiteDatabase db, final String accountId, final String contact) {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(TABLE_CONTACTS);
qb.setProjectionMap(sContactsProjectionMap);
mQueryContactIdSelectionArgs2[0] = accountId;
mQueryContactIdSelectionArgs2[1] = contact;
Cursor c = qb.query(db, CONTACT_ID_PROJECTION, CONTACT_ID_QUERY_SELECTION,
mQueryContactIdSelectionArgs2, null, null, null, null);
long contactId = 0;
try {
if (c.moveToFirst()) {
contactId = c.getLong(CONTACT_ID_COLUMN);
}
} finally {
c.close();
}
return contactId;
}
示例2: queryOne
import net.sqlcipher.database.SQLiteQueryBuilder; //导入方法依赖的package包/类
public Cursor queryOne(Context context, Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
queryBuilder.setTables(getTableName());
queryBuilder.appendWhere(getIDColumnName() + "=" + uri.getLastPathSegment());
Cursor cursor = queryBuilder.query(mDB, projection, selection, selectionArgs, null, null, sortOrder);
cursor.setNotificationUri(context.getContentResolver(), uri);
return cursor;
}
示例3: queryAll
import net.sqlcipher.database.SQLiteQueryBuilder; //导入方法依赖的package包/类
public Cursor queryAll(Context context, Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
queryBuilder.setTables(getTableName());
Cursor cursor = queryBuilder.query(mDB, projection, selection, selectionArgs, null, null, sortOrder);
cursor.setNotificationUri(context.getContentResolver(), uri);
return cursor;
}
示例4: queryOneDistinct
import net.sqlcipher.database.SQLiteQueryBuilder; //导入方法依赖的package包/类
public Cursor queryOneDistinct(Context context, Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
queryBuilder.setTables(getTableName());
queryBuilder.appendWhere(getIDColumnName() + "=" + uri.getLastPathSegment());
queryBuilder.setDistinct(true); // "true" specifies distinct results
Cursor cursor = queryBuilder.query(mDB, projection, selection, selectionArgs, null, null, sortOrder);
cursor.setNotificationUri(context.getContentResolver(), uri);
return cursor;
}
示例5: queryAllDistinct
import net.sqlcipher.database.SQLiteQueryBuilder; //导入方法依赖的package包/类
public Cursor queryAllDistinct(Context context, Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
queryBuilder.setTables(getTableName());
queryBuilder.setDistinct(true); // "true" specifies distinct results
Cursor cursor = queryBuilder.query(mDB, projection, selection, selectionArgs, null, null, sortOrder);
cursor.setNotificationUri(context.getContentResolver(), uri);
return cursor;
}
示例6: query
import net.sqlcipher.database.SQLiteQueryBuilder; //导入方法依赖的package包/类
private Cursor query(final SQLiteDatabase db, SQLiteQueryBuilder qb, String[] projection,
String selection, String[] selectionArgs, String sortOrder, String groupBy,
String having, String limit /*, CancellationSignal cancellationSignal*/) {
if (projection != null && projection.length == 1
&& ScBaseColumns._COUNT.equals(projection[0])) {
qb.setProjectionMap(sCountProjectionMap);
}
final Cursor c = qb.query(db, projection, selection, selectionArgs, groupBy, having,
sortOrder, limit/*, cancellationSignal*/);
if (c != null) {
c.setNotificationUri(getContext().getContentResolver(), ScContactsContract.AUTHORITY_URI);
}
return c;
}
示例7: queryEntities
import net.sqlcipher.database.SQLiteQueryBuilder; //导入方法依赖的package包/类
public Cursor queryEntities(String[] projection, String selection, String[] selectionArgs, String order) {
SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
builder.setTables(TABLE_KEYSTORE);
builder.setProjectionMap(mGeoTrackColumnMap);
Cursor cursor = builder.query( getReadableDatabase(), projection, selection, selectionArgs, null, null, order);
return cursor;
}
示例8: query_internal
import net.sqlcipher.database.SQLiteQueryBuilder; //导入方法依赖的package包/类
private Cursor query_internal(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder){
Timber.d("Querying URI: %s", uri);
// find object from uri
Object sourceObject = getObjectFromUri(uri);
initializeDependencies();
SQLiteDatabase database = openHelper.get().getReadableDatabase();
if (database == null) {
Timber.e("Database could not be opened");
return null;
}
Cursor cursor;
// check type of instance data set
if (Dataset.class.isInstance(sourceObject)) {
Dataset dataset = ((Dataset) sourceObject);
// logQuery(dataset, projection, selection, selectionArgs, sortOrder);
switch (dataset.getType()) {
case QUERY:
String query = prepareQuery(dataset.getSource(), projection, selection, sortOrder);
cursor = database.rawQuery(query, selectionArgs);
break;
case SQL:
cursor = database.rawQuery(selection, selectionArgs);
break;
case TABLE:
case VIEW:
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
queryBuilder.setTables(dataset.getSource());
cursor = queryBuilder.query(database, projection, selection, selectionArgs, null, null, sortOrder);
break;
default:
throw new IllegalArgumentException("Type of dataset not defined");
}
} else {
throw new IllegalArgumentException("Object sourceObject of mapContent is not instance of dataset");
}
// notify listeners waiting for the data is ready
cursor.setNotificationUri(getContext().getContentResolver(), uri);
if (!cursor.isClosed()) {
Timber.d("Rows returned: %d", cursor.getCount());
}
return cursor;
}
示例9: query
import net.sqlcipher.database.SQLiteQueryBuilder; //导入方法依赖的package包/类
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)
{
// Using SQLiteQueryBuilder instead of query() method
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
int uriType = sURIMatcher.match(uri);
// Check if the caller has requested a column which does not exists
checkColumns(projection, uriType);
switch (uriType)
{
case ADDRESS_ID:
// Adding the ID to the original query
queryBuilder.appendWhere(AddressesTable.COLUMN_ID + "=" + uri.getLastPathSegment());
case ADDRESSES:
queryBuilder.setTables(AddressesTable.TABLE_ADDRESSES);
break;
case ADDRESS_BOOK_RECORD_ID:
// Adding the ID to the original query
queryBuilder.appendWhere(AddressBookRecordsTable.COLUMN_ID + "=" + uri.getLastPathSegment());
case ADDRESS_BOOK_RECORDS:
queryBuilder.setTables(AddressBookRecordsTable.TABLE_ADDRESS_BOOK_RECORDS);
break;
case MESSAGE_ID:
// Adding the ID to the original query
queryBuilder.appendWhere(MessagesTable.COLUMN_ID + "=" + uri.getLastPathSegment());
case MESSAGES:
queryBuilder.setTables(MessagesTable.TABLE_MESSAGES);
break;
case QUEUE_RECORD_ID:
// Adding the ID to the original query
queryBuilder.appendWhere(QueueRecordsTable.COLUMN_ID + "=" + uri.getLastPathSegment());
case QUEUE_RECORDS:
queryBuilder.setTables(QueueRecordsTable.TABLE_QUEUE_RECORDS);
break;
case PAYLOAD_ID:
// Adding the ID to the original query
queryBuilder.appendWhere(PayloadsTable.COLUMN_ID + "=" + uri.getLastPathSegment());
case PAYLOADS:
queryBuilder.setTables(PayloadsTable.TABLE_PAYLOADS);
break;
case PUBKEY_ID:
// Adding the ID to the original query
queryBuilder.appendWhere(PubkeysTable.COLUMN_ID + "=" + uri.getLastPathSegment());
case PUBKEYS:
queryBuilder.setTables(PubkeysTable.TABLE_PUBKEYS);
break;
case SERVER_RECORD_ID:
// Adding the ID to the original query
queryBuilder.appendWhere(ServerRecordsTable.COLUMN_ID + "=" + uri.getLastPathSegment());
case SERVER_RECORDS:
queryBuilder.setTables(ServerRecordsTable.TABLE_SERVER_RECORDS);
break;
default:
throw new IllegalArgumentException("Unknown URI: " + uri + " Exception occurred in DatabaseContentProvider.query()");
}
Cursor cursor = queryBuilder.query(sDatabase, projection, selection, selectionArgs, null, null, sortOrder);
// make sure that potential listeners are getting notified
cursor.setNotificationUri(sContext.getContentResolver(), uri);
return cursor;
}
示例10: getFastScrollingIndexExtras43
import net.sqlcipher.database.SQLiteQueryBuilder; //导入方法依赖的package包/类
/**
* Computes counts by the address book index labels and returns it as {@link Bundle} which
* will be appended to a {@link Cursor} as extras.
*
* This function does not use the Android specific SQLite extension GET_PHONEBOOK_INDEX(...) anymore.
* Instead it uses some new fields of the RawContact that hold the primary and secondary labels and
* counts. Refer to the database helper class. This was copied from Jelly Bean 4.3 Contact application.
*/
private static Bundle getFastScrollingIndexExtras43(final Uri queryUri, final SQLiteDatabase db,
final SQLiteQueryBuilder qb, final String selection, final String[] selectionArgs,
final String sortOrder, String countExpression) {
String sortKey;
// The sort order suffix could be something like "DESC".
// We want to preserve it in the query even though we will change
// the sort column itself.
String sortOrderSuffix = "";
if (sortOrder != null) {
int spaceIndex = sortOrder.indexOf(' ');
if (spaceIndex != -1) {
sortKey = sortOrder.substring(0, spaceIndex);
sortOrderSuffix = sortOrder.substring(spaceIndex);
} else {
sortKey = sortOrder;
}
} else {
sortKey = RawContacts.SORT_KEY_PRIMARY;
}
String bucketKey;
String labelKey;
if (TextUtils.equals(sortKey, RawContacts.SORT_KEY_PRIMARY)) {
bucketKey = RawContactsColumns.PHONEBOOK_BUCKET_PRIMARY;
labelKey = RawContactsColumns.PHONEBOOK_LABEL_PRIMARY;
} else if (TextUtils.equals(sortKey, RawContacts.SORT_KEY_ALTERNATIVE)) {
bucketKey = RawContactsColumns.PHONEBOOK_BUCKET_ALTERNATIVE;
labelKey = RawContactsColumns.PHONEBOOK_LABEL_ALTERNATIVE;
} else {
return null;
}
HashMap<String, String> projectionMap = Maps.newHashMap();
projectionMap.put(AddressBookIndexQuery43.NAME,
sortKey + " AS " + AddressBookIndexQuery43.NAME);
projectionMap.put(AddressBookIndexQuery43.BUCKET,
bucketKey + " AS " + AddressBookIndexQuery43.BUCKET);
projectionMap.put(AddressBookIndexQuery43.LABEL,
labelKey + " AS " + AddressBookIndexQuery43.LABEL);
// If "what to count" is not specified, we just count all records.
if (TextUtils.isEmpty(countExpression)) {
countExpression = "*";
}
projectionMap.put(AddressBookIndexQuery43.COUNT,
"COUNT(" + countExpression + ") AS " + AddressBookIndexQuery43.COUNT);
qb.setProjectionMap(projectionMap);
String orderBy = AddressBookIndexQuery43.BUCKET + sortOrderSuffix
+ ", " + AddressBookIndexQuery43.NAME + " COLLATE "
+ PHONEBOOK_COLLATOR_NAME + sortOrderSuffix;
Cursor indexCursor = qb.query(db, AddressBookIndexQuery43.COLUMNS, selection, selectionArgs,
AddressBookIndexQuery43.GROUP_BY, null /* having */,
orderBy, null);
try {
int numLabels = indexCursor.getCount();
String labels[] = new String[numLabels];
int counts[] = new int[numLabels];
for (int i = 0; i < numLabels; i++) {
indexCursor.moveToNext();
labels[i] = indexCursor.getString(AddressBookIndexQuery43.COLUMN_LABEL);
counts[i] = indexCursor.getInt(AddressBookIndexQuery43.COLUMN_COUNT);
}
return FastScrollingIndexCache.buildExtraBundle(labels, counts);
} finally {
indexCursor.close();
}
}
示例11: query
import net.sqlcipher.database.SQLiteQueryBuilder; //导入方法依赖的package包/类
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
// Don't block caller if NON_BLOCK parameter is true and if DB is not ready
if (returnOnBlocking(uri))
return null;
final SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(Tables.CALLS);
qb.setProjectionMap(sCallsProjectionMap);
// qb.setStrict(true); TODO - available since API 14
final SelectionBuilder selectionBuilder = new SelectionBuilder(selection);
final int match = sURIMatcher.match(uri);
switch (match) {
case CALLS:
break;
case CALLS_ID: {
selectionBuilder.addClause(DbQueryUtils.getEqualityClause(ScCalls._ID, parseCallIdFromUri(uri)));
break;
}
case CALLS_FILTER: {
String phoneNumber = uri.getPathSegments().get(2);
qb.appendWhere("PHONE_NUMBERS_EQUAL(number, ");
qb.appendWhereEscapeString(phoneNumber);
qb.appendWhere(mUseStrictPhoneNumberComparation ? ", 1)" : ", 0)");
break;
}
default:
throw new IllegalArgumentException("Unknown URL " + uri);
}
final int limit = getIntParam(uri, ScCalls.LIMIT_PARAM_KEY, 0);
final int offset = getIntParam(uri, ScCalls.OFFSET_PARAM_KEY, 0);
String limitClause = null;
if (limit > 0) {
limitClause = offset + "," + limit;
}
final SQLiteDatabase db = mDbHelper.getDatabase(false);
final Cursor c = qb.query(db, projection, selectionBuilder.build(), selectionArgs, null, null, sortOrder, limitClause);
if (c != null) {
c.setNotificationUri(getContext().getContentResolver(), CallLog.CONTENT_URI);
}
return c;
}