本文整理匯總了Java中android.database.sqlite.SQLiteQueryBuilder.query方法的典型用法代碼示例。如果您正苦於以下問題:Java SQLiteQueryBuilder.query方法的具體用法?Java SQLiteQueryBuilder.query怎麽用?Java SQLiteQueryBuilder.query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.database.sqlite.SQLiteQueryBuilder
的用法示例。
在下文中一共展示了SQLiteQueryBuilder.query方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: query
import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Override
public Cursor query(Uri uri, String[] strings, String s, String[] strings1, String s1) {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
switch (sURLMatcher.match(uri)) {
case TRANSFER_INSTANCE:
qb.setTables(Constants.TABLE_NAME);
break;
case TRANSFER_INSTANCE_ID:
qb.setTables(Constants.TABLE_NAME);
qb.appendWhere(Constants.InstanceColumns.ID + "=");
qb.appendWhere(uri.getLastPathSegment());
break;
default:
throw new IllegalArgumentException("Unknown URL " + uri);
}
SQLiteDatabase database = mDbHelper.getReadableDatabase();
Cursor ret = qb.query(database, strings, s, strings1, null, null, s1);
if (ret == null) {
LogUtils.e(TAG, "query error, uri: " + uri);
} else {
ret.setNotificationUri(getContext().getContentResolver(), uri);
}
return ret;
}
示例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();
checkColumns(projection);
int type = URI_MATCHER.match(uri);
switch (type){
case NOTES:
queryBuilder.setTables(Constants.NOTES_TABLE);
break;
case NOTE:
queryBuilder.setTables(Constants.NOTES_TABLE);
queryBuilder.appendWhere(Constants.COLUMN_ID + " = " + uri.getLastPathSegment());
break;
default:
throw new IllegalArgumentException("Unknown URI: " + uri);
}
SQLiteDatabase db = dbHelper.getWritableDatabase();
Cursor cursor = queryBuilder.query(db, projection, selection, selectionArgs, null, null, sortOrder);
cursor.setNotificationUri(getContext().getContentResolver(), uri);
return cursor;
}
示例4: getMoviesFromReferenceTable
import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
private Cursor getMoviesFromReferenceTable(String tableName, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder sqLiteQueryBuilder = new SQLiteQueryBuilder();
// tableName INNER JOIN movies ON tableName.movie_id = movies._id
sqLiteQueryBuilder.setTables(
tableName + " INNER JOIN " + MoviesContract.MovieEntry.TABLE_NAME +
" ON " + tableName + "." + MoviesContract.COLUMN_MOVIE_ID_KEY +
" = " + MoviesContract.MovieEntry.TABLE_NAME + "." + MoviesContract.MovieEntry._ID
);
return sqLiteQueryBuilder.query(dbHelper.getReadableDatabase(),
projection,
selection,
selectionArgs,
null,
null,
sortOrder
);
}
示例5: 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;
}
示例6: fetchAll
import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
/**
* Return a Cursor that contains all FailedActionParameter records which matches the parameters.
*
* @param failedActionID
* is id of failed action it belongs to, or null to fetch any
* @param actionParameterName
* name of action parameter, or null to fetch any
* @param failedActionParameterData
* is the data associated with this parameter, or null to fetch any
* @return a Cursor that contains all FailedActionParameter records which matches the parameters.
*/
public Cursor fetchAll(Long failedActionID, String actionParameterName,
String failedActionParameterData) {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(DATABASE_TABLE);
qb.appendWhere("1=1");
if (failedActionID != null) {
qb.appendWhere(" AND " + KEY_FAILEDACTIONID + " = " + failedActionID);
}
if (actionParameterName != null) {
qb.appendWhere(" AND " + KEY_ACTIONPARAMETERNAME + " = " + actionParameterName);
}
if (failedActionParameterData != null) {
qb.appendWhere(" AND " + KEY_FAILEDACTIONPARAMETERDATA + " = ");
qb.appendWhereEscapeString(failedActionParameterData);
}
// Not using additional selections, selectionArgs, groupBy, having, orderBy, set them to null.
return qb.query(database, KEYS, null, null, null, null, null);
}
示例7: 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
);
}
示例8: findCommentsByIssueId
import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
public Cursor findCommentsByIssueId(Uri uri, String[] projections, String sortOrder) {
final String issueId = uri.getPathSegments().get(uri.getPathSegments().size() - 2);
final SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
queryBuilder.setTables(CommentEntry.TABLE_NAME
+ " INNER JOIN " + UserEntry.TABLE_NAME
+ " ON " + CommentEntry.TABLE_NAME + ".CREATED_USER_ID = " + UserEntry.TABLE_NAME + "._ID "
);
final SQLiteDatabase db = mOpenHelper.getReadableDatabase();
final String selection = CommentEntry.ISSUE_ID + " = ?";
return queryBuilder.query(
db,
projections,
selection,
new String[]{issueId},
null,
null,
sortOrder);
}
示例9: findIssuesByStatusAndCreated
import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
private Cursor findIssuesByStatusAndCreated(String[] projections, String status, String created) {
final SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
queryBuilder.setTables(IssueEntry.TABLE_NAME
+ " INNER JOIN " + ProjectEntry.TABLE_NAME
+ " ON " + IssueEntry.TABLE_NAME + "." + IssueEntry.PROJECT_ID
+ "=" + ProjectEntry.TABLE_NAME + "." + ProjectEntry._ID);
queryBuilder.appendWhere(IssueEntry.STATUS + " = ? ");
queryBuilder.appendWhere("AND strftime('%s',"
+ IssueEntry.CREATED_DATE + ") - strftime('%s', ? ) > 0");
final SQLiteDatabase db = mOpenHelper.getReadableDatabase();
return queryBuilder.query(
db,
projections,
null,
new String[]{status, created},
null,
null,
IssueEntry.DEFAULT_SORT,
null,
null);
}
示例10: query
import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@WorkerThread
private Cursor query(Param param){
SQLiteQueryBuilder sqLiteQueryBuilder = getQueryBuilder();
Cursor c;
if(sqLiteQueryBuilder != null){
c = sqLiteQueryBuilder.query(
Database.getDatabase(),
param.projection,
param.selection,
param.selectionArgs,
null, null,
param.sortOrder
);
}
else {
c = Database.getDatabase().query(
getTableName(),
param.projection,
param.selection,
param.selectionArgs,
null, null,
param.sortOrder
);
}
return c;
}
示例11: query
import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
public Cursor query(
Uri uri,
String[] projection,
String selection,
String[] selectionArgs,
String sortOrder) {
SQLiteDatabase db = dbHelper.getReadableDatabase();
List<String> segments = uri.getPathSegments();
String recordId = segments.get(1);
String name = segments.get(3);
SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
builder.setTables("view_things");
builder.appendWhere("record_id = '" + recordId + "'");
builder.appendWhere(" and view_name = '" + name + "'");
Cursor cursor =
builder.query(
db,
projection,
selection,
selectionArgs,
null,
null,
sortOrder);
return cursor;
}
示例12: getMobileServer
import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
public MobileServer getMobileServer(long id){
SQLiteDatabase db = this.getReadableDatabase();
MobileServer mobileServer = new MobileServer();
mobileServer.setId(id);
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(TABLE_SERVERS +
" JOIN " + TABLE_MOBILE_SERVERS +
" USING(" + COLUMN_ID + ")");
Cursor c = qb.query(db,
new String[]{COLUMN_IS_ENABLED,
COLUMN_CERTIFICATE_ID,
COLUMN_IP_OR_HOSTNAME,
COLUMN_PORT_NUMBER,
COLUMN_ROAMING_ALLOWED},
COLUMN_ID + "=?", new String[]{String.valueOf(id)},
null, null, null);
if (c.moveToFirst()){
mobileServer.setIsEnabled(intToBool(c.getInt(0)));
mobileServer.setCertificateId(c.getLong(1));
mobileServer.setIpOrHostname(c.getString(2));
mobileServer.setPortNumber(c.getInt(3));
mobileServer.setRoamingAllowed(intToBool(c.getInt(4)));
}
c.close();
db.close();
return mobileServer;
}
示例13: getAllWifiServers
import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
private List<WifiServer> getAllWifiServers(){
List<WifiServer> allWifiServers = new ArrayList<>();
SQLiteDatabase db = this.getReadableDatabase();
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(TABLE_SERVERS +
" JOIN " + TABLE_WIFI_SERVERS +
" USING(" + COLUMN_ID + ")");
Cursor c = qb.query(db,
new String[]{COLUMN_ID,
COLUMN_IS_ENABLED,
COLUMN_CERTIFICATE_ID,
COLUMN_IP_OR_HOSTNAME,
COLUMN_PORT_NUMBER,
COLUMN_SSID_WHITELIST},
null, null, null, null, null);
if (c.moveToFirst()){
do {
WifiServer wifiServer = new WifiServer();
wifiServer.setId(c.getLong(0));
wifiServer.setIsEnabled(intToBool(c.getInt(1)));
wifiServer.setCertificateId(c.getLong(2));
wifiServer.setIpOrHostname(c.getString(3));
wifiServer.setPortNumber(c.getInt(4));
wifiServer.setSsidWhitelist(c.getString(5));
allWifiServers.add(wifiServer);
} while (c.moveToNext());
}
c.close();
db.close();
return allWifiServers;
}
示例14: getAllMobileServers
import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
private List<MobileServer> getAllMobileServers(){
List<MobileServer> allWifiAndMobileServers = new ArrayList<>();
SQLiteDatabase db = this.getReadableDatabase();
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(TABLE_SERVERS +
" JOIN " + TABLE_MOBILE_SERVERS +
" USING(" + COLUMN_ID + ")");
Cursor c = qb.query(db,
new String[]{COLUMN_ID,
COLUMN_IS_ENABLED,
COLUMN_CERTIFICATE_ID,
COLUMN_IP_OR_HOSTNAME,
COLUMN_PORT_NUMBER,
COLUMN_ROAMING_ALLOWED},
null, null, null, null, null);
if (c.moveToFirst()){
do {
MobileServer wifiAndMobileServer = new MobileServer();
wifiAndMobileServer.setId(c.getLong(0));
wifiAndMobileServer.setIsEnabled(intToBool(c.getInt(1)));
wifiAndMobileServer.setCertificateId(c.getLong(2));
wifiAndMobileServer.setIpOrHostname(c.getString(3));
wifiAndMobileServer.setPortNumber(c.getInt(4));
wifiAndMobileServer.setRoamingAllowed(intToBool(c.getInt(5)));
allWifiAndMobileServers.add(wifiAndMobileServer);
} while (c.moveToNext());
}
c.close();
db.close();
return allWifiAndMobileServers;
}
示例15: query
import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Nullable
@Override
public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
SQLiteDatabase db = dbHelper.getWritableDatabase();
SQLiteQueryBuilder sqLiteQueryBuilder = new SQLiteQueryBuilder();
sqLiteQueryBuilder.setTables(Stats.TABLE_NAME);
Cursor cursor = sqLiteQueryBuilder.query(db, projection, selection, selectionArgs, null, null, sortOrder);
cursor.setNotificationUri(context().getContentResolver(), uri);
return cursor;
}