Java Code Examples for net.sqlcipher.database.SQLiteQueryBuilder#setTables()

The following examples show how to use net.sqlcipher.database.SQLiteQueryBuilder#setTables() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImpsProvider.java    From Zom-Android-XMPP with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: ImpsProvider.java    From Zom-Android-XMPP with GNU General Public License v3.0 5 votes vote down vote up
private void buildQueryContactsByProvider(SQLiteQueryBuilder qb, StringBuilder whereClause,
        Uri url) {
    qb.setTables(CONTACT_JOIN_PRESENCE_CHAT_AVATAR_TABLE);
    qb.setProjectionMap(sContactsProjectionMap);
    // we don't really need the provider id in query. account id is enough.
    appendWhere(whereClause, Imps.Contacts.ACCOUNT, "=", url.getLastPathSegment());
}
 
Example 3
Source File: DatabaseContentProvider.java    From bitseal with GNU General Public License v3.0 4 votes vote down vote up
@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;
}