use of android.database.sqlite.SQLiteQueryBuilder in project ABPlayer by winkstu.
the class PreferenceProvider method query.
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
switch(URI_MATCHER.match(uri)) {
case PREFERENCES:
qb.setTables(TB_NAME);
break;
case PREFERENCE_KEY:
qb.setTables(TB_NAME);
qb.appendWhere(COL_KEY + "= '" + uri.getPathSegments().get(1) + "'");
break;
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
SQLiteDatabase db = mDbHelper.getReadableDatabase();
return qb.query(db, projection, selection, selectionArgs, null, null, sortOrder);
}
use of android.database.sqlite.SQLiteQueryBuilder in project Material-Movies by saulmm.
the class DbProvider method query.
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
switch(uriMatcher.match(uri)) {
case MOVIES_ID:
queryBuilder.appendWhere(DbConstants.Movies.ID + "=" + uri.getLastPathSegment());
case MOVIES:
queryBuilder.setTables(DbConstants.Movies.TABLE_NAME);
if (TextUtils.isEmpty(sortOrder)) {
sortOrder = DbConstants.Movies.DEFAULT_SORT_ORDER;
}
break;
default:
throw new IllegalArgumentException("Unknown URI: " + uri);
}
Cursor c = queryBuilder.query(database, projection, selection, selectionArgs, null, null, sortOrder);
c.setNotificationUri(getContext().getContentResolver(), uri);
return c;
}
use of android.database.sqlite.SQLiteQueryBuilder in project muzei by romannurik.
the class GalleryProvider method queryChosenPhotos.
private Cursor queryChosenPhotos(@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(GalleryContract.ChosenPhotos.TABLE_NAME);
qb.setProjectionMap(allChosenPhotosColumnProjectionMap);
final SQLiteDatabase db = databaseHelper.getReadableDatabase();
if (GalleryProvider.uriMatcher.match(uri) == CHOSEN_PHOTOS_ID) {
// If the incoming URI is for a single chosen photo identified by its ID, appends "_ID = <chosenPhotoId>"
// to the where clause, so that it selects that single chosen photo
qb.appendWhere(BaseColumns._ID + "=" + uri.getLastPathSegment());
}
String orderBy;
if (TextUtils.isEmpty(sortOrder))
orderBy = GalleryContract.ChosenPhotos.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;
}
use of android.database.sqlite.SQLiteQueryBuilder in project muzei by romannurik.
the class GalleryProvider method queryMetadataCache.
private Cursor queryMetadataCache(@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(GalleryContract.MetadataCache.TABLE_NAME);
qb.setProjectionMap(allMetadataCacheColumnProjectionMap);
final SQLiteDatabase db = databaseHelper.getReadableDatabase();
String orderBy;
if (TextUtils.isEmpty(sortOrder))
orderBy = GalleryContract.MetadataCache.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;
}
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