• nullnullDefining and Launching the Query 定义和启动查询


    PS:今天上午,非常郁闷,有很多简单基础的问题搞得我有些迷茫,哎,代码几天不写就忘。目前又不当COO,还是得用心记代码哦!

        To perform a query, create the CursorLoader, set up its query, and pass it to the loader framework. From then on, the framework manages everything. It runs the query on a background thread, returns the results to the foreground, and watches for changes to the data associated with the query. http://blog.csdn.net/sergeycao

        Pass a CursorLoader to the loader framework in your implementation ofonCreateLoader(). The loader framework calls this method when youcreate a loader by calling initLoader(). You can create aCursorLoader anywhere, but the preferred way is to create it inonCreateLoader(), because this defers creation until the object is actually needed.

        Notice that initLoader() will only onCreateLoader() if theCursorLoader doesn't already exist; otherwise, it re-uses the existingCursorLoader. The loader framework tracks CursorLoader instance using theid value passed to initLoader().

        

    Define and Launch the Query

        每日一道理
    微笑,是春天里的一丝新绿,是秋日里的一缕阳光,是骄阳下的一片浓荫,是冬雪中的一株梅红……微笑着去面对吧,你会感到人生是那样的温馨与甜蜜!

        To create a CursorLoader and define its query at the same time, call the constructorCursorLoader(context, uri, projection, selection, selectionArgs, sortOrder). Thecontext and uri arguments are required, but the others are optional. To use the default value for an optional argument, pass innull. The CursorLoader runs the query against theContentProvider identified by uri, just as if you had calledContentResolver.query() with the same arguments.

        For example:

    public Loader<Cursor> onCreateLoader(int loaderID, Bundle bundle)
    {
        /*
         * Takes action based on the ID of the Loader that's being created
         */
        switch (loaderID) {
            case URL_LOADER:
                /*
                 * Return a new CursorLoader
                 */
                return new CursorLoader(
                    this,                           // Context
                    DataProviderContract.IMAGE_URI, // Provider's content URI
                    PROJECTION,                     // Columns to return
                    null,                           // Return all rows
                    null,                           // No search arguments
                    null);                          // Default search order
            default:
                // An invalid id was passed in
                return null;
        }
    }

    文章结束给大家分享下程序员的一些笑话语录: AdobeFlash拖垮Windows拖垮IE!又拖垮Linux拖垮Ubuntu拖垮FirxEox!还拖垮BSD拖垮MacOS拖垮Safri!简直无所不拖!AdobeFlash滚出网路世界!不要以为市占有率高就可以持续出烂货产品!以后替代品多得是!

  • 相关阅读:
    54.施工方案第二季(最小生成树)
    53.FIB词链
    53.FIB词链
    53.FIB词链
    52.1076 排序
    52.1076 排序
    52.1076 排序
    52.1076 排序
    upc-9541 矩阵乘法 (矩阵分块)
    记录deepin设置自动代理
  • 原文地址:https://www.cnblogs.com/jiangu66/p/3069881.html
Copyright © 2020-2023  润新知