use of android.database.sqlite.SQLiteQueryBuilder in project mobile-android by photo.
the class UploadsProvider method query.
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(PHOTOS_TABLE);
switch(uriMatcher.match(uri)) {
case UPLOAD_ID:
qb.appendWhere(KEY_ID + "=" + uri.getPathSegments().get(1));
break;
default:
break;
}
Cursor c = qb.query(mDb, projection, selection, selectionArgs, null, null, null);
c.setNotificationUri(getContext().getContentResolver(), uri);
return c;
}
use of android.database.sqlite.SQLiteQueryBuilder in project PocketHub by pockethub.
the class Organizations method getCursor.
@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);
}
use of android.database.sqlite.SQLiteQueryBuilder in project PocketHub by pockethub.
the class AccountDataManager method query.
/**
* Query tables for columns
*
* @param helper
* @param tables
* @param columns
* @param selection
* @param selectionArgs
* @return cursor
*/
protected Cursor query(SQLiteOpenHelper helper, String tables, String[] columns, String selection, String[] selectionArgs) {
SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
builder.setTables(tables);
return builder.query(helper.getReadableDatabase(), columns, selection, selectionArgs, null, null, null);
}
use of android.database.sqlite.SQLiteQueryBuilder in project robolectric by robolectric.
the class SQLiteQueryBuilderTest method setUp.
@Before
public void setUp() throws Exception {
database = SQLiteDatabase.create(null);
database.execSQL("create table " + TABLE_NAME + " (" + COL_VALUE + " TEXT, " + COL_GROUP + " INTEGER" + ")");
ContentValues values = new ContentValues();
values.put(COL_VALUE, "record1");
values.put(COL_GROUP, 1);
firstRecordId = database.insert(TABLE_NAME, null, values);
assertThat(firstRecordId).isGreaterThan(0);
values.clear();
values.put(COL_VALUE, "record2");
values.put(COL_GROUP, 1);
long secondRecordId = database.insert(TABLE_NAME, null, values);
assertThat(secondRecordId).isGreaterThan(0).isNotEqualTo(firstRecordId);
values.clear();
values.put(COL_VALUE, "won't be selected");
values.put(COL_GROUP, 2);
database.insert(TABLE_NAME, null, values);
builder = new SQLiteQueryBuilder();
builder.setTables(TABLE_NAME);
builder.appendWhere(COL_VALUE + " <> ");
builder.appendWhereEscapeString("won't be selected");
}
use of android.database.sqlite.SQLiteQueryBuilder in project muzei by romannurik.
the class MuzeiProvider method querySource.
private Cursor querySource(@NonNull final Uri uri, final String[] projection, final String selection, final String[] selectionArgs, final String sortOrder) {
ContentResolver contentResolver = getContext() != null ? getContext().getContentResolver() : null;
if (contentResolver == null) {
return null;
}
final SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(MuzeiContract.Sources.TABLE_NAME);
qb.setProjectionMap(allSourcesColumnProjectionMap);
final SQLiteDatabase db = databaseHelper.getReadableDatabase();
if (MuzeiProvider.uriMatcher.match(uri) == SOURCE_ID) {
// If the incoming URI is for a single source identified by its ID, appends "_ID = <sourceId>"
// to the where clause, so that it selects that single source
qb.appendWhere(BaseColumns._ID + "=" + uri.getLastPathSegment());
}
String orderBy;
if (TextUtils.isEmpty(sortOrder))
orderBy = MuzeiContract.Sources.DEFAULT_SORT_ORDER;
else
orderBy = sortOrder;
final Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy, null);
c.setNotificationUri(contentResolver, uri);
return c;
}
Aggregations