本文整理汇总了Java中android.database.sqlite.SQLiteQueryBuilder.buildUnionQuery方法的典型用法代码示例。如果您正苦于以下问题:Java SQLiteQueryBuilder.buildUnionQuery方法的具体用法?Java SQLiteQueryBuilder.buildUnionQuery怎么用?Java SQLiteQueryBuilder.buildUnionQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.database.sqlite.SQLiteQueryBuilder
的用法示例。
在下文中一共展示了SQLiteQueryBuilder.buildUnionQuery方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findIssuesStatsByProjectId
import android.database.sqlite.SQLiteQueryBuilder; //导入方法依赖的package包/类
private Cursor findIssuesStatsByProjectId(Uri uri) {
final String projectId = uri.getQueryParameter(IssuePreviewEntry.QUERY_PARAMETER_PROJECT_ID);
if (projectId == null) {
throw new IllegalArgumentException("ProjectId should not be null");
}
final String subQueryOpenIssues = createIssueSubQueryWithStatus(projectId, "Open");
final String subQueryInProgressIssues = createIssueSubQueryWithStatus(projectId, "In Progress");
final String subQueryResolved = createIssueSubQueryWithStatus(projectId, "Resolved");
final SQLiteQueryBuilder unionQueryBuilder = new SQLiteQueryBuilder();
final String sql = unionQueryBuilder.buildUnionQuery(new String[]{
subQueryOpenIssues, subQueryInProgressIssues, subQueryResolved},
null, null);
return mOpenHelper.getReadableDatabase().rawQuery(sql, null);
}
示例2: sampleSQLiteQueryBuilder
import android.database.sqlite.SQLiteQueryBuilder; //导入方法依赖的package包/类
public void sampleSQLiteQueryBuilder(SQLiteQueryBuilder builder, String input) {
builder.appendWhere(input);
//buildQueryString
builder.buildQueryString(false, null, null, input, null, null, null, null);
builder.buildQueryString(false, null, null, null, input, null, null, null);
builder.buildQueryString(false, null, null, null, null, input, null, null);
builder.buildQueryString(false, null, null, null, null, null, input,null);
builder.buildQueryString(false, null, null, null, null, null,null, input);
//query no limit
builder.query(null, null, input, null, null, null,null);
builder.query(null, null, null, null, input, null,null);
builder.query(null, null, null, null,null,input,null);
builder.query(null, null, null, null,null,null,input);
//query with limit
builder.query(null, null, input, null, null, null,null, null);
builder.query(null, null, null, null, input, null,null, null);
builder.query(null, null, null, null,null,input,null, null);
builder.query(null, null, null, null,null,null,input, null);
builder.query(null, null, null, null,null,null,null, input);
//query with limit with cancellation system
builder.query(null, null, input, null, null, null,null, null, new CancellationSignal());
builder.query(null, null, null, null, input, null,null, null, new CancellationSignal());
builder.query(null, null, null, null,null,input,null, null, new CancellationSignal());
builder.query(null, null, null, null,null,null,input, null, new CancellationSignal());
builder.query(null, null, null, null,null,null,null, input, new CancellationSignal());
//buildQuery
builder.buildQuery(null, input, null, null, null, null);
builder.buildQuery(null, null, input,null, null, null);
builder.buildQuery(null, null, null, input, null, null);
builder.buildQuery(null, null, null, null, input, null);
builder.buildQuery(null, null, null, null, null, input);
//buildQuery with selectionArgs
builder.buildQuery(null, input, new String[0], null, null, null, null);
builder.buildQuery(null, null, new String[0], input, null, null, null);
builder.buildQuery(null, null, new String[0],null, input,null, null);
builder.buildQuery(null, null, new String[0],null, null, input,null);
builder.buildQuery(null, null, new String[0],null, null, null, input);
//buildUnionQuery
builder.buildUnionQuery(new String[] {input}, null, null);
builder.buildUnionQuery(null, input, null);
builder.buildUnionQuery(null, null, input);
//buildUnionSubQuery
builder.buildUnionSubQuery(null, null, null,0, null, input, null, null);
builder.buildUnionSubQuery(null, null, null,0, null, null, input, null);
builder.buildUnionSubQuery(null, null, null,0, null, null, null, input);
//buildUnionSubQuery with selectionArgs
builder.buildUnionSubQuery(null, null, null,0, null, input, new String[0],null, null);
builder.buildUnionSubQuery(null, null, null,0, null, null, new String[0], input, null);
builder.buildUnionSubQuery(null, null, null,0, null, null, new String[0], null, input);
}
示例3: queryTables
import android.database.sqlite.SQLiteQueryBuilder; //导入方法依赖的package包/类
private Cursor queryTables(String[] projection, String selection, String order, String groupBy, String limit) {
String[] mmsProjection = {MmsDatabase.DATE_SENT + " * 1000 AS " + MmsSmsColumns.NORMALIZED_DATE_SENT,
MmsDatabase.DATE_RECEIVED + " * 1000 AS " + MmsSmsColumns.NORMALIZED_DATE_RECEIVED,
MmsSmsColumns.ID, SmsDatabase.BODY, MmsSmsColumns.READ, MmsSmsColumns.THREAD_ID,
SmsDatabase.TYPE, SmsDatabase.ADDRESS, SmsDatabase.ADDRESS_DEVICE_ID, SmsDatabase.SUBJECT, MmsDatabase.MESSAGE_TYPE,
MmsDatabase.MESSAGE_BOX, SmsDatabase.STATUS, MmsDatabase.PART_COUNT,
MmsDatabase.CONTENT_LOCATION, MmsDatabase.TRANSACTION_ID,
MmsDatabase.MESSAGE_SIZE, MmsDatabase.EXPIRY, MmsDatabase.STATUS,
MmsSmsColumns.RECEIPT_COUNT, TRANSPORT};
String[] smsProjection = {SmsDatabase.DATE_SENT + " * 1 AS " + MmsSmsColumns.NORMALIZED_DATE_SENT,
SmsDatabase.DATE_RECEIVED + " * 1 AS " + MmsSmsColumns.NORMALIZED_DATE_RECEIVED,
MmsSmsColumns.ID, SmsDatabase.BODY, MmsSmsColumns.READ, MmsSmsColumns.THREAD_ID,
SmsDatabase.TYPE, SmsDatabase.ADDRESS, SmsDatabase.ADDRESS_DEVICE_ID, SmsDatabase.SUBJECT, MmsDatabase.MESSAGE_TYPE,
MmsDatabase.MESSAGE_BOX, SmsDatabase.STATUS, MmsDatabase.PART_COUNT,
MmsDatabase.CONTENT_LOCATION, MmsDatabase.TRANSACTION_ID,
MmsDatabase.MESSAGE_SIZE, MmsDatabase.EXPIRY, MmsDatabase.STATUS,
MmsSmsColumns.RECEIPT_COUNT, TRANSPORT};
SQLiteQueryBuilder mmsQueryBuilder = new SQLiteQueryBuilder();
SQLiteQueryBuilder smsQueryBuilder = new SQLiteQueryBuilder();
mmsQueryBuilder.setDistinct(true);
smsQueryBuilder.setDistinct(true);
mmsQueryBuilder.setTables(MmsDatabase.TABLE_NAME);
smsQueryBuilder.setTables(SmsDatabase.TABLE_NAME);
Set<String> mmsColumnsPresent = new HashSet<String>();
mmsColumnsPresent.add(MmsSmsColumns.ID);
mmsColumnsPresent.add(MmsSmsColumns.READ);
mmsColumnsPresent.add(MmsSmsColumns.THREAD_ID);
mmsColumnsPresent.add(MmsSmsColumns.BODY);
mmsColumnsPresent.add(MmsSmsColumns.ADDRESS);
mmsColumnsPresent.add(MmsSmsColumns.ADDRESS_DEVICE_ID);
mmsColumnsPresent.add(MmsSmsColumns.RECEIPT_COUNT);
mmsColumnsPresent.add(MmsDatabase.MESSAGE_TYPE);
mmsColumnsPresent.add(MmsDatabase.MESSAGE_BOX);
mmsColumnsPresent.add(MmsDatabase.DATE_SENT);
mmsColumnsPresent.add(MmsDatabase.DATE_RECEIVED);
mmsColumnsPresent.add(MmsDatabase.PART_COUNT);
mmsColumnsPresent.add(MmsDatabase.CONTENT_LOCATION);
mmsColumnsPresent.add(MmsDatabase.TRANSACTION_ID);
mmsColumnsPresent.add(MmsDatabase.MESSAGE_SIZE);
mmsColumnsPresent.add(MmsDatabase.EXPIRY);
mmsColumnsPresent.add(MmsDatabase.STATUS);
Set<String> smsColumnsPresent = new HashSet<String>();
smsColumnsPresent.add(MmsSmsColumns.ID);
smsColumnsPresent.add(MmsSmsColumns.BODY);
smsColumnsPresent.add(MmsSmsColumns.ADDRESS);
smsColumnsPresent.add(MmsSmsColumns.ADDRESS_DEVICE_ID);
smsColumnsPresent.add(MmsSmsColumns.READ);
smsColumnsPresent.add(MmsSmsColumns.THREAD_ID);
smsColumnsPresent.add(MmsSmsColumns.RECEIPT_COUNT);
smsColumnsPresent.add(SmsDatabase.TYPE);
smsColumnsPresent.add(SmsDatabase.SUBJECT);
smsColumnsPresent.add(SmsDatabase.DATE_SENT);
smsColumnsPresent.add(SmsDatabase.DATE_RECEIVED);
smsColumnsPresent.add(SmsDatabase.STATUS);
String mmsSubQuery = mmsQueryBuilder.buildUnionSubQuery(TRANSPORT, mmsProjection, mmsColumnsPresent, 2, MMS_TRANSPORT, selection, null, null, null);
String smsSubQuery = smsQueryBuilder.buildUnionSubQuery(TRANSPORT, smsProjection, smsColumnsPresent, 2, SMS_TRANSPORT, selection, null, null, null);
SQLiteQueryBuilder unionQueryBuilder = new SQLiteQueryBuilder();
String unionQuery = unionQueryBuilder.buildUnionQuery(new String[] {smsSubQuery, mmsSubQuery}, order, null);
SQLiteQueryBuilder outerQueryBuilder = new SQLiteQueryBuilder();
outerQueryBuilder.setTables("(" + unionQuery + ")");
String query = outerQueryBuilder.buildQuery(projection, null, null, groupBy, null, null, limit);
Log.w("MmsSmsDatabase", "Executing query: " + query);
SQLiteDatabase db = databaseHelper.getReadableDatabase();
return db.rawQuery(query, null);
}