本文整理汇总了Java中android.database.sqlite.SQLiteQueryBuilder类的典型用法代码示例。如果您正苦于以下问题:Java SQLiteQueryBuilder类的具体用法?Java SQLiteQueryBuilder怎么用?Java SQLiteQueryBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SQLiteQueryBuilder类属于android.database.sqlite包,在下文中一共展示了SQLiteQueryBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getObservations
import android.database.sqlite.SQLiteQueryBuilder; //导入依赖的package包/类
public Cursor getObservations() {
SQLiteDatabase db = getReadableDatabase();
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
String [] sqlSelect = {
"_id",
ObsTable.Cols.DsoID,
ObsTable.Cols.ObsDate,
ObsTable.Cols.Location,
ObsTable.Cols.Seeing,
ObsTable.Cols.Transparency,
ObsTable.Cols.Telescope,
ObsTable.Cols.Eyepiece,
ObsTable.Cols.Power,
ObsTable.Cols.Filter,
ObsTable.Cols.Notes
};
qb.setTables(ObsTable.NAME);
Cursor c = qb.query(db, sqlSelect, null, null, null, null, null);
c.moveToFirst();
return c;
}
示例2: query
import android.database.sqlite.SQLiteQueryBuilder; //导入依赖的package包/类
@Override
public Cursor query(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
db = mBotDatabase.getReadableDatabase();
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
queryBuilder.setTables(BotContracts.TABLE_NAME);
switch (sUriMatcher.match(uri)) {
case 1:
break;
case 2:
queryBuilder.appendWhere(BotContracts.COLUMN_ID + "=" + uri.getPathSegments().get(1));
break;
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
if (sortOrder == null || sortOrder == "") {
sortOrder = BotContracts.COLUMN_BOT_NAME;
}
Cursor c = queryBuilder.query(db, projection, selection, selectionArgs, null, null, sortOrder);
c.setNotificationUri(getContext().getContentResolver(), uri);
return c;
}
示例3: query
import android.database.sqlite.SQLiteQueryBuilder; //导入依赖的package包/类
@Override
public Cursor query(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
int uriType = sURIMatcher.match(uri);
switch (uriType) {
case SIMPLEENTITY_DIR:
queryBuilder.setTables(TABLENAME);
break;
case SIMPLEENTITY_ID:
queryBuilder.setTables(TABLENAME);
queryBuilder.appendWhere(PK + "="
+ uri.getLastPathSegment());
break;
default:
throw new IllegalArgumentException("Unknown URI: " + uri);
}
Database db = getDatabase();
Cursor cursor = queryBuilder.query(((StandardDatabase) db).getSQLiteDatabase(), projection, selection,
selectionArgs, null, null, sortOrder);
cursor.setNotificationUri(getContext().getContentResolver(), uri);
return cursor;
}
示例4: query
import android.database.sqlite.SQLiteQueryBuilder; //导入依赖的package包/类
/**
* Query the database
*/
private Cursor query(String selection, String[] selectionArgs) {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
// main INNER JOIN frequency ON (main._id=freq.pair_id)
qb.setTables(MAIN_TABLE_NAME + " INNER JOIN " + FREQ_TABLE_NAME + " ON ("
+ MAIN_TABLE_NAME + "." + MAIN_COLUMN_ID + "=" + FREQ_TABLE_NAME + "."
+ FREQ_COLUMN_PAIR_ID +")");
qb.setProjectionMap(sDictProjectionMap);
// Get the database and run the query
SQLiteDatabase db = sOpenHelper.getReadableDatabase();
Cursor c = qb.query(db,
new String[] { MAIN_COLUMN_WORD1, MAIN_COLUMN_WORD2, FREQ_COLUMN_FREQUENCY },
selection, selectionArgs, null, null, null);
return c;
}
示例5: queryBookListing
import android.database.sqlite.SQLiteQueryBuilder; //导入依赖的package包/类
/**
* @param selection A filter declaring which rows to return, formatted as an SQL WHERE clause (excluding the WHERE itself). Passing null will return all rows
* @param selectionArgs You may include ?s in selection, which will be replaced by the values from selectionArgs, in order that they appear in the selection. The values will be bound as Strings.
* @return a cursor over the result set coulms are those specified by {@link BooksInformationDbHelper#BOOK_LISTING_PROJECTION}
*/
private Cursor queryBookListing(String selection, String[] selectionArgs) {
SQLiteDatabase db = this.getReadableDatabase();
SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
builder.setTables(BOOKS_JOIN_AUTHORS);
return builder.query(db,
BOOK_LISTING_PROJECTION,
selection,
selectionArgs,
null,
null,
null);
}
示例6: query
import android.database.sqlite.SQLiteQueryBuilder; //导入依赖的package包/类
/**
* Performs a database query.
* @param selection The selection clause
* @param selectionArgs Selection arguments for "?" components in the selection
* @param columns The columns to return
* @return A Cursor over all rows matching the query
*/
private Cursor query(String selection, String[] selectionArgs, String[] columns) {
/* The SQLiteBuilder provides a map for all possible columns requested to
* actual columns in the database, creating a simple column alias mechanism
* by which the ContentProvider does not need to know the real column names
*/
SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
builder.setTables(FTS_VIRTUAL_TABLE);
builder.setProjectionMap(mColumnMap);
Cursor cursor = builder.query(mDatabaseOpenHelper.getReadableDatabase(),
columns, selection, selectionArgs, null, null, null);
if (cursor == null) {
return null;
} else if (!cursor.moveToFirst()) {
cursor.close();
return null;
}
return cursor;
}
示例7: handleMovieFull
import android.database.sqlite.SQLiteQueryBuilder; //导入依赖的package包/类
private static void handleMovieFull(SQLiteQueryBuilder qb) {
if(DBG) Log.d(TAG, "File is a movie.");
qb.setTables(ScraperTables.MOVIE_TABLE_NAME +
" LEFT JOIN " + ScraperTables.FILMS_MOVIE_VIEW_NAME + " ON (" +
ScraperTables.MOVIE_TABLE_NAME + "." +
ScraperStore.Movie.ID + " = " +
ScraperTables.FILMS_MOVIE_VIEW_NAME + "." +
ScraperStore.Movie.Director.MOVIE + ") " +
"LEFT JOIN " + ScraperTables.PLAYS_MOVIE_VIEW_NAME + " ON (" +
ScraperTables.MOVIE_TABLE_NAME + "." +
ScraperStore.Movie.ID + " = " +
ScraperTables.PLAYS_MOVIE_VIEW_NAME + "." +
ScraperStore.Movie.Actor.MOVIE + ") " +
"LEFT JOIN " + ScraperTables.PRODUCES_MOVIE_VIEW_NAME + " ON (" +
ScraperTables.MOVIE_TABLE_NAME + "." +
ScraperStore.Movie.ID + " = " +
ScraperTables.PRODUCES_MOVIE_VIEW_NAME + "." +
ScraperStore.Movie.Studio.MOVIE + ") " +
"LEFT JOIN " + ScraperTables.BELONGS_MOVIE_VIEW_NAME + " ON (" +
ScraperTables.MOVIE_TABLE_NAME + "." +
ScraperStore.Movie.ID + " = " +
ScraperTables.BELONGS_MOVIE_VIEW_NAME + "." +
ScraperStore.Movie.Genre.MOVIE + ")");
}
示例8: handleShowFull
import android.database.sqlite.SQLiteQueryBuilder; //导入依赖的package包/类
private static void handleShowFull(SQLiteQueryBuilder qb) {
if(DBG) Log.d(TAG, "File is a TV show.");
qb.setTables(ScraperTables.SHOW_TABLE_NAME + " LEFT JOIN " +
ScraperTables.FILMS_SHOW_VIEW_NAME + " ON (" +
ScraperTables.SHOW_TABLE_NAME + "." +
ScraperStore.Show.ID + " = " +
ScraperTables.FILMS_SHOW_VIEW_NAME + "." +
ScraperStore.Show.Director.SHOW + ") " +
"LEFT JOIN " + ScraperTables.PLAYS_SHOW_VIEW_NAME + " ON (" +
ScraperTables.SHOW_TABLE_NAME + "." +
ScraperStore.Show.ID + " = " +
ScraperTables.PLAYS_SHOW_VIEW_NAME + "." +
ScraperStore.Show.Actor.SHOW + ") " +
"LEFT JOIN " + ScraperTables.PRODUCES_SHOW_VIEW_NAME + " ON (" +
ScraperTables.SHOW_TABLE_NAME + "." +
ScraperStore.Show.ID + " = " +
ScraperTables.PRODUCES_SHOW_VIEW_NAME + "." +
ScraperStore.Show.Studio.SHOW + ") " +
"LEFT JOIN " + ScraperTables.BELONGS_SHOW_VIEW_NAME + " ON (" +
ScraperTables.SHOW_TABLE_NAME + "." +
ScraperStore.Show.ID + " = " +
ScraperTables.BELONGS_SHOW_VIEW_NAME + "." +
ScraperStore.Show.Genre.SHOW + ")");
}
示例9: query
import android.database.sqlite.SQLiteQueryBuilder; //导入依赖的package包/类
@Nullable
@Override
public Cursor query(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(TABLE_NAME);
qb.setProjectionMap(values);
switch (uriMatcher.match(uri)) {
case API:
break;
case API_GET:
qb.appendWhere(id + "=" + uri.getLastPathSegment());
break;
default:
throw new IllegalArgumentException("Unknown URI : " + uri);
}
if (sortOrder == null || sortOrder.equals("")) {
sortOrder = name;
}
Cursor c = qb.query(db, projection, selection, selectionArgs, null,
null, sortOrder);
c.setNotificationUri(getContext().getContentResolver(), uri);
return c;
}
示例10: query
import android.database.sqlite.SQLiteQueryBuilder; //导入依赖的package包/类
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
int matchCode = mUriMatcher.match(uri);
if (matchCode < 0) {
throw new IllegalArgumentException("Invalid query URI: " + uri);
}
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
if (isItemUri(matchCode)) {
queryBuilder.appendWhere(BaseColumns._ID + "=" + uri.getLastPathSegment());
}
queryBuilder.setTables(getTableName(matchCode));
SQLiteDatabase db = getDatabase(false);
Cursor cursor = queryBuilder.query(db, projection, selection, selectionArgs, null, null, sortOrder);
cursor.setNotificationUri(getContext().getContentResolver(), uri);
return cursor;
}
示例11: query
import android.database.sqlite.SQLiteQueryBuilder; //导入依赖的package包/类
protected Cursor query(Uri uri, String tableName, String[] columns, String selection, String[] selectionArgs, String sortOrder) {
String orderBy = sortOrder;
if (TextUtils.isEmpty(sortOrder))
orderBy = "_id asc";
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(tableName);
mDb = mDbHelper.getWritableDatabase();
return qb.query(mDb,
columns,
selection,
selectionArgs,
null,
null,
orderBy
);
}
示例12: queryById
import android.database.sqlite.SQLiteQueryBuilder; //导入依赖的package包/类
protected Cursor queryById(Uri uri, String tableName, String[] columns, String selection, String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(tableName);
StringBuilder w = new StringBuilder();
w.append("_id = ");
w.append(uri.getLastPathSegment());
if (selection != null) {
w.append(" AND (");
w.append(selection);
w.append(")");
}
mDb = mDbHelper.getWritableDatabase();
return qb.query(mDb,
columns,
w.toString(),
selectionArgs,
null,
null,
sortOrder
);
}
示例13: query
import android.database.sqlite.SQLiteQueryBuilder; //导入依赖的package包/类
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
String sortOrder) {
int key = uriMatcher.match(uri);
String table = "";
switch (key) {
case M_NOTE://0
table = tblNote.TBL_NAME;
break;
default:
break;
}
SQLiteDatabase sqlDB = mDbHelper.getWritableDatabase();
SQLiteQueryBuilder sqlBuilder = new SQLiteQueryBuilder();
sqlBuilder.setTables(table);
sqlBuilder.setDistinct(true);
Cursor c = sqlBuilder.query(sqlDB, projection, selection, selectionArgs, null, null,
sortOrder);
c.setNotificationUri(getContext().getContentResolver(), uri);
return c;
}
示例14: query
import android.database.sqlite.SQLiteQueryBuilder; //导入依赖的package包/类
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
queryBuilder.setTables(sqLiteOpenHelper.TABLE_NAME);
switch (uriMatcher.match(uri)){
case PLACES_ID:
queryBuilder.setProjectionMap(PlaceMap);
break;
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
if (sortOrder == null || sortOrder == ""){
sortOrder = sqLiteOpenHelper.ID;
}
Cursor cursor = queryBuilder.query(database, projection, selection,
selectionArgs, null, null, sortOrder);
cursor.setNotificationUri(getContext().getContentResolver(), uri);
return cursor;
}
示例15: query
import android.database.sqlite.SQLiteQueryBuilder; //导入依赖的package包/类
@Nullable
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(Settings.TABLE_NAME);
switch (sUriMatcher.match(uri)){
case SETTINGS:
qb.setProjectionMap(sProjectionMap);
break;
case SETTINGS_ID:
qb.setProjectionMap(sProjectionMap);
qb.appendWhere(
Settings._ID +"="+uri.getPathSegments().get(1)
);
break;
default:
throw new IllegalArgumentException("Unknown uri: "+uri);
}
SQLiteDatabase db = mOPenHelper.getReadableDatabase();
Cursor c = qb.query(db,projection,selection,selectionArgs,null,null,sortOrder);
c.setNotificationUri(getContext().getContentResolver(),uri);
return c;
}