當前位置: 首頁>>代碼示例>>Java>>正文


Java SQLiteQueryBuilder.setDistinct方法代碼示例

本文整理匯總了Java中android.database.sqlite.SQLiteQueryBuilder.setDistinct方法的典型用法代碼示例。如果您正苦於以下問題:Java SQLiteQueryBuilder.setDistinct方法的具體用法?Java SQLiteQueryBuilder.setDistinct怎麽用?Java SQLiteQueryBuilder.setDistinct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.database.sqlite.SQLiteQueryBuilder的用法示例。


在下文中一共展示了SQLiteQueryBuilder.setDistinct方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
                    String sortOrder) {

    int key = uriMatcher.match(uri);
    String table = "";

    switch (key) {
        case M_NOTE://0
            table = tblNote.TBL_NAME;
            break;
        default:
            break;
    }

    SQLiteDatabase sqlDB = mDbHelper.getWritableDatabase();
    SQLiteQueryBuilder sqlBuilder = new SQLiteQueryBuilder();
    sqlBuilder.setTables(table);
    sqlBuilder.setDistinct(true);
    Cursor c = sqlBuilder.query(sqlDB, projection, selection, selectionArgs, null, null,
            sortOrder);
    c.setNotificationUri(getContext().getContentResolver(), uri);
    return c;
}
 
開發者ID:tuyendt6,項目名稱:WindowsNoteMaster,代碼行數:25,代碼來源:DatabaseManager.java

示例2: performJoinQuery

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
private Cursor performJoinQuery(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    QueryCorrector qc = new UriQueryCorrector(uri, selection, selectionArgs);
    SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
    builder.setTables(UriJoinTranslator.joinStringFrom(uri));
    boolean isDistinct = Boolean.parseBoolean(uri.getQueryParameter("DISTINCT"));
    builder.setDistinct(isDistinct);
    final String limit = qc.getLimit() > 0 ? String.valueOf(qc.getLimit()) : null;
    return builder.query(FSDBHelper.inst().getReadableDatabase(),
            projection,
            qc.getSelection(true),
            qc.getSelectionArgs(),
            null,
            null,
            sortOrder,
            limit);
}
 
開發者ID:ryansgot,項目名稱:forsuredbandroid,代碼行數:17,代碼來源:FSDefaultProvider.java

示例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);
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:78,代碼來源:MmsSmsDatabase.java


注:本文中的android.database.sqlite.SQLiteQueryBuilder.setDistinct方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。