qb.setDistinct(useDistinct); Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy);
public void setDistinct(boolean distinct) { delegate.setDistinct(distinct); }
public SelectQuery<T> uniqueOnly() { mSQLiteQueryBuilder.setDistinct(true); return this; }
@Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { ... final SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); qb.setDistinct(true);
qb.setDistinct(useDistinct);
public Cursor getData(){ SQLiteDatabase db = getReadableDatabase(); SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); String [] sqlSelect = {"0 _id", "state"}; String sqlTables = "Reefs"; qb.setTables(sqlTables); qb.setDistinct(true); Cursor c = qb.query(db, sqlSelect, null, null, null, null, null); c.moveToFirst(); return c; }
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; }
SQLiteQueryBuilder sqLiteQueryBuilder = new SQLiteQueryBuilder(); sqLiteQueryBuilder.setTables("A, B"); sqLiteQueryBuilder.setDistinct(true); String selection = "A.ID = B.ID"; Cursor c = sqLiteQueryBuilder.query(db, new String[]{"A.x"}, selection, null, null, null, null);
public void testUnionQuery() { String expected; String[] innerProjection = new String[] {"name", "age", "location"}; SQLiteQueryBuilder employeeQueryBuilder = new SQLiteQueryBuilder(); SQLiteQueryBuilder peopleQueryBuilder = new SQLiteQueryBuilder(); employeeQueryBuilder.setTables("employee"); peopleQueryBuilder.setTables("people"); String employeeSubQuery = employeeQueryBuilder.buildUnionSubQuery( "_id", innerProjection, null, 2, "employee", "age=25", null, null, null); String peopleSubQuery = peopleQueryBuilder.buildUnionSubQuery( "_id", innerProjection, null, 2, "people", "location=LA", null, null, null); expected = "SELECT name, age, location FROM employee WHERE (age=25)"; assertEquals(expected, employeeSubQuery); expected = "SELECT name, age, location FROM people WHERE (location=LA)"; assertEquals(expected, peopleSubQuery); SQLiteQueryBuilder unionQueryBuilder = new SQLiteQueryBuilder(); unionQueryBuilder.setDistinct(true); String unionQuery = unionQueryBuilder.buildUnionQuery( new String[] { employeeSubQuery, peopleSubQuery }, null, null); expected = "SELECT name, age, location FROM employee WHERE (age=25) " + "UNION SELECT name, age, location FROM people WHERE (location=LA)"; assertEquals(expected, unionQuery); }
switch (uriParser.matched()) { case TIMELINE: qb.setDistinct(true); qb.setTables(TimelineSql.tablesForTimeline(uri, projection)); qb.setProjectionMap(ProjectionMap.TIMELINE);