PS:今天上午,非常郁闷,有很多简单基础的问题搞得我有些迷茫,哎,代码几天不写就忘。目前又不当COO,还是得用心记代码哦!
To perform a query, create the , 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 to the loader framework in your implementation of
. The loader framework calls this method when youcreate a loader by calling
. You can create a
anywhere, but the preferred way is to create it in
, because this defers creation until the object is actually needed.
Notice that will only
if the
doesn't already exist; otherwise, it re-uses the existing
. The loader framework tracks
instance using the
id
value passed to .
Define and Launch the Query
To create a and define its query at the same time, call the constructor
. The
context
and uri
arguments are required, but the others are optional. To use the default value for an optional argument, pass innull
. The runs the query against the
identified by
uri
, just as if you had called with the same arguments.
For example:
public LoaderonCreateLoader(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滚出网路世界!不要以为市占有率高就可以持续出烂货产品!以后替代品多得是!