当前位置: 首页>>代码示例>>Java>>正文


Java Cursor.setNotificationUri方法代码示例

本文整理汇总了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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:SimpleEntityContentProvider.java

示例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;
}
 
开发者ID:jgilfelt,项目名称:chuck,代码行数:27,代码来源:ChuckContentProvider.java

示例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;
}
 
开发者ID:vpaliyX,项目名称:Melophile,代码行数:20,代码来源:MusicProvider.java

示例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;
}
 
开发者ID:nejtv,项目名称:androidtv-sample,代码行数:34,代码来源:VideoProvider.java

示例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;
}
 
开发者ID:odoo-mobile-intern,项目名称:odoo-work,代码行数:13,代码来源:BaseContentProvider.java

示例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;
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:33,代码来源:RepoProvider.java

示例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;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:10,代码来源:RecipientPreferenceDatabase.java

示例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;
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:35,代码来源:TaskContentProvider.java

示例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;
}
 
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:15,代码来源:SunagoContentProvider.java

示例10: setNotifyConverationListeners

import android.database.Cursor; //导入方法依赖的package包/类
protected void setNotifyConverationListeners(Cursor cursor, long threadId) {
  cursor.setNotificationUri(context.getContentResolver(), Uri.parse(CONVERSATION_URI + threadId));
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:4,代码来源:Database.java

示例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;
}
 
开发者ID:gusbru,项目名称:pets,代码行数:63,代码来源:PetProvider.java

示例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;
}
 
开发者ID:changja88,项目名称:Udacity_Sunshine,代码行数:52,代码来源:WeatherProvider.java

示例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;
}
 
开发者ID:an-garcia,项目名称:MovieGuide,代码行数:42,代码来源:FavoritesProvider.java

示例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;
}
 
开发者ID:graviton57,项目名称:TVGuide,代码行数:66,代码来源:TvContentProvider.java

示例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;
}
 
开发者ID:limpoxe,项目名称:Android-DownloadManager,代码行数:72,代码来源:DownloadProvider.java


注:本文中的android.database.Cursor.setNotificationUri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。