本文整理匯總了Java中android.database.Cursor.setNotificationUri方法的典型用法代碼示例。如果您正苦於以下問題:Java Cursor.setNotificationUri方法的具體用法?Java Cursor.setNotificationUri怎麽用?Java Cursor.setNotificationUri使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.database.Cursor
的用法示例。
在下文中一共展示了Cursor.setNotificationUri方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: query
import android.database.Cursor; //導入方法依賴的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.Cursor; //導入方法依賴的package包/類
@Override
@Nullable
public Cursor query(@NonNull Uri uri, @Nullable String[] projection,
@Nullable String selection, @Nullable String[] selectionArgs,
@Nullable String sortOrder) {
SQLiteDatabase db = databaseHelper.getWritableDatabase();
Cursor cursor = null;
switch (matcher.match(uri)) {
case TRANSACTIONS:
cursor = LocalCupboard.getInstance().withDatabase(db).query(HttpTransaction.class).
withProjection(projection).
withSelection(selection, selectionArgs).
orderBy(sortOrder).
getCursor();
break;
case TRANSACTION:
cursor = LocalCupboard.getInstance().withDatabase(db).query(HttpTransaction.class).
byId(ContentUris.parseId(uri)).
getCursor();
break;
}
if (cursor != null) {
cursor.setNotificationUri(getContext().getContentResolver(), uri);
}
return cursor;
}
示例3: query
import android.database.Cursor; //導入方法依賴的package包/類
@Nullable
@Override
public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection,
@Nullable String[] selectionArgs, @Nullable String sortOrder) {
final SQLiteDatabase db=database.getReadableDatabase();
final MusicMatchEnum matchEnum=matcher.match(uri);
SqlQueryBuilder builder=buildQuery(uri,matchEnum);
Cursor cursor=builder
.where(selection,selectionArgs)
.query(db,projection,sortOrder);
Context context = getContext();
if (null != context) {
cursor.setNotificationUri(context.getContentResolver(), uri);
}
return cursor;
}
示例4: query
import android.database.Cursor; //導入方法依賴的package包/類
@Override
public Cursor query(@NonNull Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
Cursor retCursor;
switch (sUriMatcher.match(uri)) {
case SEARCH_SUGGEST: {
String rawQuery = "";
if (selectionArgs != null && selectionArgs.length > 0) {
rawQuery = selectionArgs[0];
}
retCursor = getSuggestions(rawQuery);
break;
}
case VIDEO: {
retCursor = mOpenHelper.getReadableDatabase().query(
VideoContract.VideoEntry.TABLE_NAME,
projection,
selection,
selectionArgs,
null,
null,
sortOrder
);
break;
}
default: {
throw new UnsupportedOperationException("Unknown uri: " + uri);
}
}
retCursor.setNotificationUri(mContentResolver, uri);
return retCursor;
}
示例5: query
import android.database.Cursor; //導入方法依賴的package包/類
@Nullable
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String order) {
OModel model = getModel(getContext(), uri);
setMatcher(model);
SQLiteDatabase db = model.getWritableDatabase();
Cursor cr = db.query(model.getTableName(), projection, selection, selectionArgs, null, null, order);
Context ctx = getContext();
if (cr != null && ctx != null)
cr.setNotificationUri(ctx.getContentResolver(), uri);
return cr;
}
示例6: query
import android.database.Cursor; //導入方法依賴的package包/類
@Override
public Cursor query(Uri uri, String[] projection,
String selection, String[] selectionArgs, String sortOrder) {
if (TextUtils.isEmpty(sortOrder)) {
sortOrder = Cols.PRIORITY + " ASC";
}
switch (MATCHER.match(uri)) {
case CODE_LIST:
// Do nothing (don't restrict query)
break;
case CODE_SINGLE:
selection = (selection == null ? "" : selection + " AND ") +
Cols._ID + " = " + uri.getLastPathSegment();
break;
case CODE_ALL_EXCEPT_SWAP:
selection = "COALESCE(" + Cols.IS_SWAP + ", 0) = 0 ";
break;
default:
Log.e(TAG, "Invalid URI for repo content provider: " + uri);
throw new UnsupportedOperationException("Invalid URI for repo content provider: " + uri);
}
Cursor cursor = db().query(getTableName(), projection,
selection, selectionArgs, null, null, sortOrder);
cursor.setNotificationUri(getContext().getContentResolver(), uri);
return cursor;
}
示例7: getBlocked
import android.database.Cursor; //導入方法依賴的package包/類
public Cursor getBlocked() {
SQLiteDatabase database = databaseHelper.getReadableDatabase();
Cursor cursor = database.query(TABLE_NAME, new String[] {ID, RECIPIENT_IDS}, BLOCK + " = 1",
null, null, null, null, null);
cursor.setNotificationUri(context.getContentResolver(), Uri.parse(RECIPIENT_PREFERENCES_URI));
return cursor;
}
示例8: query
import android.database.Cursor; //導入方法依賴的package包/類
@Override
public Cursor query(@NonNull Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
// Get access to underlying database (read-only for query)
final SQLiteDatabase db = mTaskDbHelper.getReadableDatabase();
// Write URI match code and set a variable to return a Cursor
int match = sUriMatcher.match(uri);
Cursor retCursor;
// Query for the tasks directory and write a default case
switch (match) {
// Query for the tasks directory
case TASKS:
retCursor = db.query(TABLE_NAME,
projection,
selection,
selectionArgs,
null,
null,
sortOrder);
break;
// Default exception
default:
throw new UnsupportedOperationException("Unknown uri: " + uri);
}
// Set a notification URI on the Cursor and return that Cursor
retCursor.setNotificationUri(getContext().getContentResolver(), uri);
// Return the desired Cursor
return retCursor;
}
示例9: query
import android.database.Cursor; //導入方法依賴的package包/類
@Nullable
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
String sortOrder) {
switch (URI_MATCHER.match(uri)) {
case 2:
selection = selection + "_ID = " + uri.getLastPathSegment();
break;
}
SQLiteDatabase db = openHelper.getReadableDatabase();
Cursor cursor = db.query("items", projection, selection, selectionArgs, null, null, sortOrder);
cursor.setNotificationUri(getContext().getContentResolver(), uri);
return cursor;
}
示例10: setNotifyConverationListeners
import android.database.Cursor; //導入方法依賴的package包/類
protected void setNotifyConverationListeners(Cursor cursor, long threadId) {
cursor.setNotificationUri(context.getContentResolver(), Uri.parse(CONVERSATION_URI + threadId));
}
示例11: query
import android.database.Cursor; //導入方法依賴的package包/類
/**
* ********** QUERY ***********
*
* @param uri
* @param projection
* @param selection
* @param selectionArgs
* @param sortOrder
* @return
*/
@Nullable
@Override
public Cursor query(@NonNull Uri uri,
@Nullable String[] projection,
@Nullable String selection,
@Nullable String[] selectionArgs,
@Nullable String sortOrder) {
// read the database
SQLiteDatabase database = mPetDbHelper.getReadableDatabase();
// Declare the Cursor to be returned in the end
Cursor cursor;
// Run the Uri Matcher
final int matcher = sUriMathcer.match(uri);
// Select between PETS or PETS_ID case
switch (matcher) {
case PETS:
cursor = database.query(
PetEntry.TABLE_NAME,
projection,
selection,
selectionArgs,
null,
null,
sortOrder);
break;
case PETS_ID:
selection = PetEntry._ID + "=?";
selectionArgs = new String[]{String.valueOf(ContentUris.parseId(uri))};
cursor = database.query(
PetEntry.TABLE_NAME,
projection,
selection,
selectionArgs,
null,
null,
sortOrder);
break;
default:
throw new IllegalArgumentException("Cannot query unknown URI " + uri);
}
// Set notification URI to the cursor
cursor.setNotificationUri(getContext().getContentResolver(), uri);
return cursor;
}
示例12: query
import android.database.Cursor; //導入方法依賴的package包/類
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
String sortOrder) {
// Here's the switch statement that, given a URI, will determine what kind of request it is,
// and query the database accordingly.
Cursor retCursor;
switch (sUriMatcher.match(uri)) {
// "weather/*/*"
case WEATHER_WITH_LOCATION_AND_DATE:
{
retCursor = getWeatherByLocationSettingAndDate(uri, projection, sortOrder);
break;
}
// "weather/*"
case WEATHER_WITH_LOCATION: {
retCursor = getWeatherByLocationSetting(uri, projection, sortOrder);
break;
}
// "weather"
case WEATHER: {
retCursor = mOpenHelper.getReadableDatabase().query(
WeatherContract.WeatherEntry.TABLE_NAME,
projection,
selection,
selectionArgs,
null,
null,
sortOrder
);
break;
}
// "location"
case LOCATION: {
retCursor = mOpenHelper.getReadableDatabase().query(
WeatherContract.LocationEntry.TABLE_NAME,
projection,
selection,
selectionArgs,
null,
null,
sortOrder
);
break;
}
default:
throw new UnsupportedOperationException("Unknown uri: " + uri);
}
retCursor.setNotificationUri(getContext().getContentResolver(), uri);
return retCursor;
}
示例13: query
import android.database.Cursor; //導入方法依賴的package包/類
@Override
public Cursor query(@NonNull Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
SQLiteDatabase db = helper.getReadableDatabase();
SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
switch (sUriMatcher.match(uri)) {
case MOVIES:
builder.setTables(FavoritesContract.FavoriteColumns.FAVORITE_MOVIES_TBL);
break;
case MOVIE_ID:
builder.setTables(FavoritesContract.FavoriteColumns.FAVORITE_MOVIES_TBL);
builder.appendWhere(FavoritesContract.FavoriteColumns.COLUMN_MOVIE_ID
+ " = " + uri.getLastPathSegment());
break;
case TV_SHOWS:
builder.setTables(FavoritesContract.FavoriteColumns.FAVORITE_TV_SHOWS_TBL);
break;
case TV_SHOW_ID:
builder.setTables(FavoritesContract.FavoriteColumns.FAVORITE_TV_SHOWS_TBL);
builder.appendWhere(FavoritesContract.FavoriteColumns.COLUMN_TV_SHOW_ID
+ " = " + uri.getLastPathSegment());
break;
case PERSONS:
builder.setTables(FavoritesContract.FavoriteColumns.FAVORITE_PERSON_TBL);
break;
case PERSON_ID:
builder.setTables(FavoritesContract.FavoriteColumns.FAVORITE_PERSON_TBL);
builder.appendWhere(FavoritesContract.FavoriteColumns.COLUMN_PERSON_ID
+ " = " + uri.getLastPathSegment());
break;
default:
throw new IllegalArgumentException("Unsupported URI: " + uri);
}
Cursor returnCursor =
builder.query(db, projection, selection, selectionArgs, null, null, sortOrder);
returnCursor.setNotificationUri(getContext().getContentResolver(), uri);
return returnCursor;
}
示例14: query
import android.database.Cursor; //導入方法依賴的package包/類
@Override
public Cursor query(@NonNull Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
Cursor retCursor;
switch (sUriMatcher.match(uri)) {
// "category"
case CATEGORY: {
retCursor = openHelper.getReadableDatabase().query(
sCategoryQueryBuilder.getTables(),
projection,
selection,
selectionArgs,
null,
null,
sortOrder
);
break;
}
// "category/*"
case CATEGORY_WITH_ID: {
retCursor = getCategoryById(uri, projection, sortOrder);
break;
}
// "channel"
case CHANNEL: {
retCursor = openHelper.getReadableDatabase().query(
sChannelQueryBuilder.getTables(),
projection,
selection,
selectionArgs,
null,
null,
sortOrder
);
break;
}
// "channel/*"
case CHANNEL_WITH_ID: {
retCursor = getChannelById(uri, projection, sortOrder);
break;
}
// "program"
case PROGRAM: {
retCursor = openHelper.getReadableDatabase().query(
ProgramEntry.TABLE_NAME,
projection,
selection,
selectionArgs,
null,
null,
sortOrder
);
break;
}
// "program/*"
case PROGRAM_WITH_ID: {
retCursor = getProgramById(uri, projection, sortOrder);
break;
}
default:
throw new UnsupportedOperationException("Unknown uri: " + uri);
}
retCursor.setNotificationUri(getContext().getContentResolver(), uri);
return retCursor;
}
示例15: query
import android.database.Cursor; //導入方法依賴的package包/類
/**
* Starts a database query
*/
@Override
public Cursor query(final Uri uri, String[] projection,
final String selection, final String[] selectionArgs,
final String sort) {
Helpers.validateSelection(selection, sAppReadableColumnsSet);
SQLiteDatabase db = mOpenHelper.getReadableDatabase();
int match = sURIMatcher.match(uri);
if (match == -1) {
if (Constants.LOGV) {
Log.v(Constants.TAG, "querying unknown URI: " + uri);
}
throw new IllegalArgumentException("Unknown URI: " + uri);
}
if (match == REQUEST_HEADERS_URI) {
if (projection != null || selection != null || sort != null) {
throw new UnsupportedOperationException("Request header queries do not support "
+ "projections, selections or sorting");
}
return queryRequestHeaders(db, uri);
}
SqlSelection fullSelection = getWhereClause(uri, selection, selectionArgs, match);
if (shouldRestrictVisibility()) {
if (projection == null) {
projection = sAppReadableColumnsArray.clone();
} else {
// check the validity of the columns in projection
for (int i = 0; i < projection.length; ++i) {
if (!sAppReadableColumnsSet.contains(projection[i])) {
throw new IllegalArgumentException("column " + projection[i] + " is not allowed in queries");
}
}
}
for (int i = 0; i < projection.length; i++) {
final String newColumn = sColumnsMap.get(projection[i]);
if (newColumn != null) {
projection[i] = newColumn;
}
}
}
if (Constants.LOGVV) {
logVerboseQueryInfo(projection, selection, selectionArgs, sort, db);
}
Cursor ret = db.query(DB_TABLE, projection, fullSelection.getSelection(),
fullSelection.getParameters(), null, null, sort);
if (ret != null) {
ret.setNotificationUri(getContext().getContentResolver(), uri);
if (Constants.LOGVV) {
Log.v(Constants.TAG,
"created cursor " + ret + " on behalf of " + Binder.getCallingPid());
}
} else {
if (Constants.LOGV) {
Log.v(Constants.TAG, "query failed in downloads database");
}
}
return ret;
}