Codota Logo
SQLiteQueryBuilder
Code IndexAdd Codota to your IDE (free)

How to use
SQLiteQueryBuilder
in
android.database.sqlite

Best Java code snippets using android.database.sqlite.SQLiteQueryBuilder (Showing top 20 results out of 657)

Refine searchRefine arrow

  • Cursor
  • Common ways to obtain SQLiteQueryBuilder
private void myMethod () {
SQLiteQueryBuilder s =
  • Codota Iconnew SQLiteQueryBuilder()
  • Smart code suggestions by Codota
}
origin: stackoverflow.com

 public Cursor query(Uri uri, String[] projection, String selection,
      String[] selectionArgs, String sortOrder) {
  String groupBy = null;
  switch (mUriMatcher.match(uri)) {
   case PERSON_ID:
     ...
     break;
   case PERSON_GENDER:
     groupBy = GENDER_COLUMN;
   case PERSON:
    SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
    builder.setTables(mPersonTable);
    builder.setProjectionMap(mProjectionMap);
    return builder.query(db, projection, selection, selectionArgs, groupBy, having, sortOrder, limit);
   default:
     break;
  }
}
origin: stackoverflow.com

SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
    queryBuilder.appendWhere(TodoTable.COLUMN_ID + "="
        + uri.getLastPathSegment());
    queryBuilder.setTables(TodoTable.TABLE_TODO);
    break;
    queryBuilder.appendWhere(ReminderTable.COLUMN_ID + "="
        + uri.getLastPathSegment());
    queryBuilder.setTables(ReminderTable.TABLE_REMINDER);
    break;
origin: pockethub/PocketHub

@Override
public Cursor getCursor(SQLiteDatabase readableDatabase) {
  SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
  builder.setTables("orgs JOIN users ON (orgs.id = users.id)");
  return builder
      .query(readableDatabase, new String[] { "users.id",
          "users.name", "users.avatarurl" }, null, null, null,
          null, null);
}
origin: stackoverflow.com

 public Cursor getRegionData(String whichState) {
  SQLiteDatabase db = getReadableDatabase();
  SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
  String [] sqlSelect = {"0 _id", "region" };
  String [] theState = { whichState };
  String sqlTables = "Reefs";
  qb.setTables(sqlTables);
  qb.setDistinct(true);
  Cursor c = qb.query(db, sqlSelect, "state=?", theState, null, null, null);
  c.moveToFirst();
  return c;
}
origin: stackoverflow.com

 SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables("PROPS");
SQLiteDatabase db = dbHelper.getReadableDatabase();
Cursor c = qb.query(db, new String[]{"value"}, "name = '" + name +"'", null, null, null, null);
if(c.getCount() > 0) {
 c.moveToFirst();
 val = c.getString(c.getColumnIndexOrThrow("value"));
}
closeDbAndCursor(db,c);
origin: robolectric/robolectric

@Test
public void shouldBeAbleToMakeQueriesWithSelection() {
 Cursor cursor = builder.query(database, new String[] {"rowid"}, COL_VALUE + "=?", new String[] {"record1"}, null, null, null);
 assertThat(cursor.getCount()).isEqualTo(1);
 assertThat(cursor.moveToNext()).isTrue();
 assertThat(cursor.getLong(0)).isEqualTo(firstRecordId);
}
origin: Microsoft/AppCenter-SDK-Android

@Override
public int countLogs(@NonNull String group) {
  /* Query database and get scanner. */
  SQLiteQueryBuilder builder = SQLiteUtils.newSQLiteQueryBuilder();
  builder.appendWhere(COLUMN_GROUP + " = ?");
  int count = 0;
  try {
    Cursor cursor = mDatabaseManager.getCursor(builder, new String[]{"COUNT(*)"}, new String[]{group}, null);
    try {
      cursor.moveToNext();
      count = cursor.getInt(0);
    } finally {
      cursor.close();
    }
  } catch (RuntimeException e) {
    AppCenterLog.error(LOG_TAG, "Failed to get logs count: ", e);
  }
  return count;
}
origin: denzilferreira/aware-client

/**
 * Query entries from the database
 */
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
  initialiseDatabase();
  SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
  qb.setStrict(true);
  switch (sUriMatcher.match(uri)) {
    case ACCEL_DEV:
      qb.setTables(DATABASE_TABLES[0]);
      qb.setProjectionMap(accelDeviceMap);
      break;
    case ACCEL_DATA:
      qb.setTables(DATABASE_TABLES[1]);
      qb.setProjectionMap(accelDataMap);
      break;
    default:
      throw new IllegalArgumentException("Unknown URI " + uri);
  }
  try {
    Cursor c = qb.query(database, projection, selection, selectionArgs, null, null, sortOrder);
    c.setNotificationUri(getContext().getContentResolver(), uri);
    return c;
  } catch (IllegalStateException e) {
    if (Aware.DEBUG) Log.e(Aware.TAG, e.getMessage());
    return null;
  }
}
origin: Microsoft/AppCenter-SDK-Android

@SuppressWarnings("TryFinallyCanBeTryWithResources")
private static ContentValues get(DatabaseManager databaseManager, long id) {
  try {
    SQLiteQueryBuilder builder = SQLiteUtils.newSQLiteQueryBuilder();
    builder.appendWhere(DatabaseManager.PRIMARY_KEY + " = ?");
    String[] selectionArgs = new String[]{String.valueOf(id)};
    Cursor cursor = databaseManager.getCursor(builder, null, selectionArgs, null);
    try {
      return databaseManager.nextValues(cursor);
    } finally {
      cursor.close();
    }
  } catch (RuntimeException e) {
    return null;
  }
}
origin: robolectric/robolectric

@Test
public void shouldBeAbleToMakeQueries() {
 Cursor cursor = builder.query(database, new String[] {"rowid"}, null, null, null, null, null);
 assertThat(cursor.getCount()).isEqualTo(2);
}
origin: stackoverflow.com

  String[] selectionArgs, String sortOrder)
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
  useDistinct = true;
case YOUR_URI:
  qb.setTables(YOUR_TABLE_NAME);
  qb.setProjectionMap(sYourProjectionMap);
  break;
qb.setDistinct(useDistinct);
Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy);
  c.setNotificationUri(getContext().getContentResolver(), uri);
origin: stackoverflow.com

 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
      && BaseColumns._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(), ContactsContract.AUTHORITY_URI);
  }
  return c;
}
origin: stackoverflow.com

SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
      "p2.id = r.related_id AND " + 
      "p2.id = ?", args);
  cursor.setNotificationUri(getContext().getContentResolver(), uri);
  return cursor;
...
origin: geniusgithub/AndroidDialer

@Nullable
@Override
public Cursor query(Uri uri,
          @Nullable String[] projection,
          @Nullable String selection,
          @Nullable String[] selectionArgs,
          @Nullable String sortOrder) {
  SQLiteDatabase db = mDialerDatabaseHelper.getReadableDatabase();
  SQLiteQueryBuilder queryBuilder = getQueryBuilder(uri);
  Cursor cursor = queryBuilder
      .query(db, projection, selection, selectionArgs, null, null, sortOrder);
  if (cursor != null) {
    cursor.setNotificationUri(getContext().getContentResolver(),
        VoicemailArchiveContract.VoicemailArchive.CONTENT_URI);
  }
  return cursor;
}
origin: stackoverflow.com

 // The projection map is a hashmap of strings
HashMap<String, String> MyProjectionMap;
MyProjectionMap = new HashMap<String, String>();

// Add column mappings to the projection map
MyProjectionMap.put(Tasks._ID, Tasks._ID);
MyProjectionMap.put(Tasks.TITLE, Tasks.TITLE);
[...]

SQLiteQueryBuilder qb;
qb.setTables("tasks");
qb.setProjectionMap(MyProjectionMap)

// Then do your query
Cursor c = qb.query(db, projection, ...)
origin: stackoverflow.com

 SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
queryBuilder.setTables(ProfessionalTable.TABLE_NAME);
origin: arminha/worldclockwidget

private SQLiteQueryBuilder createQueryBuilder() {
  SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
  qb.setTables(Clocks.TABLE_NAME);
  qb.setProjectionMap(PROJECTION_MAP);
  // TODO from API 14 on we could use strict mode
  // qb.setStrict(true);
  return qb;
}
origin: stackoverflow.com

    sb, usageType == null ? USAGE_TYPE_ALL : usageType, DataColumns.CONCRETE_ID);
qb.setTables(sb.toString());
qb.setDistinct(useDistinct);
qb.setProjectionMap(projectionMap);
appendAccountIdFromParameter(qb, uri);
origin: Coinomi/coinomi-android

private static void appendAddresses(@Nonnull final SQLiteQueryBuilder qb, @Nonnull final String[] addresses) {
  for (final String address : addresses) {
    qb.appendWhereEscapeString(address.trim());
    if (!address.equals(addresses[addresses.length - 1]))
      qb.appendWhere(",");
  }
}
origin: novoda/sqlite-provider

public void appendWhere(CharSequence inWhere) {
  delegate.appendWhere(inWhere);
}
android.database.sqliteSQLiteQueryBuilder

Most used methods

  • setTables
  • <init>
  • query
  • appendWhere
  • setProjectionMap
  • appendWhereEscapeString
  • setDistinct
  • buildQuery
  • buildQueryString
  • getTables
  • buildUnionQuery
  • buildUnionSubQuery
  • buildUnionQuery,
  • buildUnionSubQuery,
  • setStrict,
  • setCursorFactory

Popular in Java

  • Running tasks concurrently on multiple threads
  • setContentView (Activity)
  • onCreateOptionsMenu (Activity)
  • getSharedPreferences (Context)
  • ObjectMapper (com.fasterxml.jackson.databind)
    This mapper (or, data binder, or codec) provides functionality for converting between Java objects (
  • FileOutputStream (java.io)
    A file output stream is an output stream for writing data to aFile or to a FileDescriptor. Whether
  • PrintStream (java.io)
    A PrintStream adds functionality to another output stream, namely the ability to print representatio
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now