android.support.v4.content.CursorLoader Java Examples
The following examples show how to use
android.support.v4.content.CursorLoader.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ListFragment.java From android-galaxyzoo with GNU General Public License v3.0 | 6 votes |
@Override public Loader<Cursor> onCreateLoader(final int loaderId, final Bundle bundle) { if (loaderId != URL_LOADER) { return null; } final Activity activity = getActivity(); final Uri uriItems = Item.ITEMS_URI; return new CursorLoader( activity, uriItems, mColumns, null, // No where clause, return all records. null, // No where clause, therefore no where column values. null // Use the default sort order. ); }
Example #2
Source File: MediaStoreRetriever.java From Camera-Roll-Android-App with Apache License 2.0 | 6 votes |
public static String getPathForUri(Context context, Uri uri) { CursorLoader cursorLoader = new CursorLoader( context, uri, new String[]{MediaStore.Files.FileColumns.DATA}, null, null, null); try { final Cursor cursor = cursorLoader.loadInBackground(); if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst(); return cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns.DATA)); } return null; } catch (SecurityException e) { Toast.makeText(context, "Permission Error", Toast.LENGTH_SHORT).show(); return null; } }
Example #3
Source File: ContactListFilterView.java From zom-android-matrix with Apache License 2.0 | 6 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { StringBuilder buf = new StringBuilder(); if (mSearchString != null) { buf.append(Imps.Contacts.NICKNAME); buf.append(" LIKE "); DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%"); buf.append(" OR "); buf.append(Imps.Contacts.USERNAME); buf.append(" LIKE "); DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%"); } CursorLoader loader = new CursorLoader(getContext(), mUri, ContactListItem.CONTACT_PROJECTION, buf == null ? null : buf.toString(), null, Imps.Contacts.DEFAULT_SORT_ORDER); // loader.setUpdateThrottle(10L); return loader; }
Example #4
Source File: ContactListFilterView.java From Zom-Android-XMPP with GNU General Public License v3.0 | 6 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { StringBuilder buf = new StringBuilder(); if (mSearchString != null) { buf.append(Imps.Contacts.NICKNAME); buf.append(" LIKE "); DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%"); buf.append(" OR "); buf.append(Imps.Contacts.USERNAME); buf.append(" LIKE "); DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%"); } CursorLoader loader = new CursorLoader(getContext(), mUri, ContactListItem.CONTACT_PROJECTION, buf == null ? null : buf.toString(), null, Imps.Contacts.DEFAULT_SORT_ORDER); // loader.setUpdateThrottle(10L); return loader; }
Example #5
Source File: LoaderRetainedSupport.java From V.FlyoutTest with MIT License | 6 votes |
public Loader<Cursor> onCreateLoader(int id, Bundle args) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't care about the ID. // First, pick the base URI to use depending on whether we are // currently filtering. Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath(People.CONTENT_FILTER_URI, Uri.encode(mCurFilter)); } else { baseUri = People.CONTENT_URI; } // Now create and return a CursorLoader that will take care of // creating a Cursor for the data being displayed. String select = "((" + People.DISPLAY_NAME + " NOTNULL) AND (" + People.DISPLAY_NAME + " != '' ))"; return new CursorLoader(getActivity(), baseUri, CONTACTS_SUMMARY_PROJECTION, select, null, People.DISPLAY_NAME + " COLLATE LOCALIZED ASC"); }
Example #6
Source File: RecentFragment.java From android with Apache License 2.0 | 6 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle bundle) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.getActivity()); String sortOrder = prefs.getString(Config.SORT_ORDER_RECENT, Config.SORT_RECENT_DEFAULT); String[] projection = { RecentTable.COLUMN_TITLE, RecentTable.COLUMN_LINK, RecentTable.COLUMN_IMAGE, RecentTable.COLUMN_ID, RecentTable.COLUMN_TYPE, RecentTable.COLUMN_NUM_SEASONS, RecentTable.COLUMN_SEASON, RecentTable.COLUMN_EPISODE, RecentTable.COLUMN_NUM_EPISODES, RecentTable.COLUMN_RATING}; return new CursorLoader(this.getActivity(), RecentContentProvider.CONTENT_URI, projection, null, null, sortOrder); }
Example #7
Source File: ContactsListFragment.java From zom-android-matrix with Apache License 2.0 | 6 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { StringBuilder buf = new StringBuilder(); if (mSearchString != null) { buf.append('('); buf.append(Imps.Contacts.NICKNAME); buf.append(" LIKE "); DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%"); buf.append(" OR "); buf.append(Imps.Contacts.USERNAME); buf.append(" LIKE "); DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%"); buf.append(')'); buf.append(" AND "); } buf.append(Imps.Contacts.TYPE).append('=').append(mType); // buf.append(" ) GROUP BY(" + Imps.Contacts.USERNAME); CursorLoader loader = new CursorLoader(getActivity(), mUri, ContactListItem.CONTACT_PROJECTION, buf == null ? null : buf.toString(), null, Imps.Contacts.SUB_AND_ALPHA_SORT_ORDER); return loader; }
Example #8
Source File: DetailActivityFragment.java From BuildmLearn-Toolkit-Android with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if (null != dict_Id) { switch (id) { case DETAIL_LOADER: return new CursorLoader(getActivity(), null, Constants.DICT_COLUMNS, null, null, null) { @Override public Cursor loadInBackground() { return db.getDictCursorById(Integer.parseInt(dict_Id)); } }; default: //do nothing break; } } return null; }
Example #9
Source File: DetailActivity.java From android-dev-challenge with Apache License 2.0 | 6 votes |
/** * Creates and returns a CursorLoader that loads the data for our URI and stores it in a Cursor. * * @param loaderId The loader ID for which we need to create a loader * @param loaderArgs Any arguments supplied by the caller * * @return A new Loader instance that is ready to start loading. */ @Override public Loader<Cursor> onCreateLoader(int loaderId, Bundle loaderArgs) { switch (loaderId) { case ID_DETAIL_LOADER: return new CursorLoader(this, mUri, WEATHER_DETAIL_PROJECTION, null, null, null); default: throw new RuntimeException("Loader Not Implemented: " + loaderId); } }
Example #10
Source File: DetailActivity.java From android-dev-challenge with Apache License 2.0 | 6 votes |
/** * Creates and returns a CursorLoader that loads the data for our URI and stores it in a Cursor. * * @param loaderId The loader ID for which we need to create a loader * @param loaderArgs Any arguments supplied by the caller * * @return A new Loader instance that is ready to start loading. */ @Override public Loader<Cursor> onCreateLoader(int loaderId, Bundle loaderArgs) { switch (loaderId) { case ID_DETAIL_LOADER: return new CursorLoader(this, mUri, WEATHER_DETAIL_PROJECTION, null, null, null); default: throw new RuntimeException("Loader Not Implemented: " + loaderId); } }
Example #11
Source File: ContactsListFragment.java From Zom-Android-XMPP with GNU General Public License v3.0 | 6 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { StringBuilder buf = new StringBuilder(); if (mSearchString != null) { buf.append('('); buf.append(Imps.Contacts.NICKNAME); buf.append(" LIKE "); DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%"); buf.append(" OR "); buf.append(Imps.Contacts.USERNAME); buf.append(" LIKE "); DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%"); buf.append(')'); buf.append(" AND "); } buf.append(Imps.Contacts.TYPE).append('=').append(mType); // buf.append(" ) GROUP BY(" + Imps.Contacts.USERNAME); CursorLoader loader = new CursorLoader(getActivity(), mUri, ContactListItem.CONTACT_PROJECTION, buf == null ? null : buf.toString(), null, Imps.Contacts.SUB_AND_ALPHA_SORT_ORDER); return loader; }
Example #12
Source File: DetailActivity.java From android-dev-challenge with Apache License 2.0 | 6 votes |
/** * Creates and returns a CursorLoader that loads the data for our URI and stores it in a Cursor. * * @param loaderId The loader ID for which we need to create a loader * @param loaderArgs Any arguments supplied by the caller * * @return A new Loader instance that is ready to start loading. */ @Override public Loader<Cursor> onCreateLoader(int loaderId, Bundle loaderArgs) { switch (loaderId) { case ID_DETAIL_LOADER: return new CursorLoader(this, mUri, WEATHER_DETAIL_PROJECTION, null, null, null); default: throw new RuntimeException("Loader Not Implemented: " + loaderId); } }
Example #13
Source File: Utils.java From Android-ImageManager with MIT License | 6 votes |
/** * Gets the corresponding path to a file from the given content:// URI * <p> * This must run on the main thread * * @param context * @param uri * @return the file path as a string */ public static String getContentPathFromUri(final Context context, final Uri uri) { Cursor cursor = null; String contentPath = null; try { final String[] proj = { MediaStore.Images.Media.DATA }; final CursorLoader loader = new CursorLoader(context, uri, proj, null, null, null); cursor = loader.loadInBackground(); final int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); contentPath = cursor.getString(columnIndex); } catch (final Exception e) { Log.w(TAG, "getContentPathFromURI(" + uri.toString() + "): " + e.getMessage()); } finally { if (cursor != null) cursor.close(); } return contentPath != null ? contentPath : ""; }
Example #14
Source File: MainActivity.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 6 votes |
@NonNull public Loader<Cursor> onCreateLoader(int id, Bundle args) { // Construct the new query in the form of a Cursor Loader. Use the id // parameter to construct and return different loaders. String[] projection = null; String where = null; String[] whereArgs = null; String sortOrder = null; // Query URI Uri queryUri = MyHoardContentProvider.CONTENT_URI; // Create the new Cursor loader. return new CursorLoader(this, queryUri, projection, where, whereArgs, sortOrder); }
Example #15
Source File: PhotoThumbnailFragment.java From AndroidTrainingCode with Apache License 2.0 | 6 votes |
@Override 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: // Returns a new CursorLoader return new CursorLoader( getActivity(), // Context DataProviderContract.PICTUREURL_TABLE_CONTENTURI, // Table to query PROJECTION, // Projection to return null, // No selection clause null, // No selection arguments null // Default sort order ); default: // An invalid id was passed in return null; } }
Example #16
Source File: DetailActivity.java From android-dev-challenge with Apache License 2.0 | 6 votes |
/** * Creates and returns a CursorLoader that loads the data for our URI and stores it in a Cursor. * * @param loaderId The loader ID for which we need to create a loader * @param loaderArgs Any arguments supplied by the caller * * @return A new Loader instance that is ready to start loading. */ @Override public Loader<Cursor> onCreateLoader(int loaderId, Bundle loaderArgs) { switch (loaderId) { case ID_DETAIL_LOADER: return new CursorLoader(this, mUri, WEATHER_DETAIL_PROJECTION, null, null, null); default: throw new RuntimeException("Loader Not Implemented: " + loaderId); } }
Example #17
Source File: DetailActivity.java From android-dev-challenge with Apache License 2.0 | 6 votes |
/** * Creates and returns a CursorLoader that loads the data for our URI and stores it in a Cursor. * * @param loaderId The loader ID for which we need to create a loader * @param loaderArgs Any arguments supplied by the caller * * @return A new Loader instance that is ready to start loading. */ @Override public Loader<Cursor> onCreateLoader(int loaderId, Bundle loaderArgs) { switch (loaderId) { case ID_DETAIL_LOADER: return new CursorLoader(this, mUri, WEATHER_DETAIL_PROJECTION, null, null, null); default: throw new RuntimeException("Loader Not Implemented: " + loaderId); } }
Example #18
Source File: MySearchActivity.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 6 votes |
@NonNull public Loader<Cursor> onCreateLoader(int id, Bundle args) { // Extract the search query from the Intent. String query = getIntent().getStringExtra(SearchManager.QUERY); // Construct the new query in the form of a Cursor Loader. String[] projection = { HoardDB.HoardContract.KEY_ID, HoardDB.HoardContract.KEY_GOLD_HOARD_NAME_COLUMN, HoardDB.HoardContract.KEY_GOLD_HOARDED_COLUMN }; String where = HoardDB.HoardContract.KEY_GOLD_HOARD_NAME_COLUMN + " LIKE ?"; String[] whereArgs = {"%" + query + "%"}; String sortOrder = HoardDB.HoardContract.KEY_GOLD_HOARD_NAME_COLUMN + " COLLATE LOCALIZED ASC"; // Create the new Cursor loader. return new CursorLoader(this, MyHoardContentProvider.CONTENT_URI, projection, where, whereArgs, sortOrder); }
Example #19
Source File: DetailActivity.java From android-dev-challenge with Apache License 2.0 | 6 votes |
/** * Creates and returns a CursorLoader that loads the data for our URI and stores it in a Cursor. * * @param loaderId The loader ID for which we need to create a loader * @param loaderArgs Any arguments supplied by the caller * @return A new Loader instance that is ready to start loading. */ @Override public Loader<Cursor> onCreateLoader(int loaderId, Bundle loaderArgs) { switch (loaderId) { // COMPLETED (23) If the loader requested is our detail loader, return the appropriate CursorLoader case ID_DETAIL_LOADER: return new CursorLoader(this, mUri, WEATHER_DETAIL_PROJECTION, null, null, null); default: throw new RuntimeException("Loader Not Implemented: " + loaderId); } }
Example #20
Source File: DetailActivity.java From android-dev-challenge with Apache License 2.0 | 6 votes |
/** * Creates and returns a CursorLoader that loads the data for our URI and stores it in a Cursor. * * @param loaderId The loader ID for which we need to create a loader * @param loaderArgs Any arguments supplied by the caller * * @return A new Loader instance that is ready to start loading. */ @Override public Loader<Cursor> onCreateLoader(int loaderId, Bundle loaderArgs) { switch (loaderId) { case ID_DETAIL_LOADER: return new CursorLoader(this, mUri, WEATHER_DETAIL_PROJECTION, null, null, null); default: throw new RuntimeException("Loader Not Implemented: " + loaderId); } }
Example #21
Source File: MainActivity.java From android-dev-challenge with Apache License 2.0 | 5 votes |
/** * Called by the {@link android.support.v4.app.LoaderManagerImpl} when a new Loader needs to be * created. This Activity only uses one loader, so we don't necessarily NEED to check the * loaderId, but this is certainly best practice. * * @param loaderId The loader ID for which we need to create a loader * @param bundle Any arguments supplied by the caller * @return A new Loader instance that is ready to start loading. */ @Override public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) { switch (loaderId) { case ID_FORECAST_LOADER: /* URI for all rows of weather data in our weather table */ Uri forecastQueryUri = WeatherContract.WeatherEntry.CONTENT_URI; /* Sort order: Ascending by date */ String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC"; /* * A SELECTION in SQL declares which rows you'd like to return. In our case, we * want all weather data from today onwards that is stored in our weather table. * We created a handy method to do that in our WeatherEntry class. */ String selection = WeatherContract.WeatherEntry.getSqlSelectForTodayOnwards(); return new CursorLoader(this, forecastQueryUri, MAIN_FORECAST_PROJECTION, selection, null, sortOrder); default: throw new RuntimeException("Loader Not Implemented: " + loaderId); } }
Example #22
Source File: JobsHNFragment.java From yahnac with Apache License 2.0 | 5 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Uri storyNewsUri = HNewsContract.StoryEntry.buildStoriesUri(); return new CursorLoader( getActivity(), storyNewsUri, HNewsContract.StoryEntry.STORY_COLUMNS, HNewsContract.StoryEntry.FILTER + " = ?", new String[]{Story.FILTER.jobs.name()}, getOrder()); }
Example #23
Source File: CategoriesViewBinder.java From fdroidclient with GNU General Public License v3.0 | 5 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if (id != LOADER_ID) { return null; } return new CursorLoader( activity, CategoryProvider.getAllCategories(), Schema.CategoryTable.Cols.ALL, null, null, null ); }
Example #24
Source File: AttendeeListFragment.java From attendee-checkin with Apache License 2.0 | 5 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { FragmentActivity activity = getActivity(); String eventId = args.getString(ARG_EVENT_ID); if (TextUtils.isEmpty(eventId)) { return null; } String selectionExtra = args.getBoolean(ARG_ONLY_COMING) ? " AND " + Table.Attendee.CHECKIN + " IS NULL" : ""; switch (id) { case LOADER_ATTENDEES: return new CursorLoader(activity, Table.ATTENDEE.getBaseUri(), new String[]{ Table.Attendee._ID, Table.Attendee.ID, Table.Attendee.EVENT_ID, Table.Attendee.EMAIL, Table.Attendee.NAME, Table.Attendee.PLUSID, Table.Attendee.IMAGE_URL, Table.Attendee.CHECKIN, Table.Attendee.CHECKIN_MODIFIED, Table.Attendee.NOTE, }, Table.Attendee.EVENT_ID + " = ?" + selectionExtra, new String[]{eventId}, Table.Attendee.NAME); case LOADER_COUNT_ALL_ATTENDEES: return new CursorLoader(activity, Table.ATTENDEE.getBaseUri(), new String[]{ "COUNT(*) AS c" }, Table.Attendee.EVENT_ID + " = ?", new String[]{eventId}, null); } return null; }
Example #25
Source File: MainActivity.java From android-samples with Apache License 2.0 | 5 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { //create the content resolver query. The syntax for the content uri should be content://authority/names/query. //This syntax represents the search operation in com.androidsample.contentprovidersample application. return new CursorLoader(this, Uri.parse("content://com.androidsample.contentprovidersample/names/" + mEditText.getText().toString().trim()), new String[]{"name", "_id"}, null, null, "name ASC"); }
Example #26
Source File: MainActivity.java From android-dev-challenge with Apache License 2.0 | 5 votes |
/** * Called by the {@link android.support.v4.app.LoaderManagerImpl} when a new Loader needs to be * created. This Activity only uses one loader, so we don't necessarily NEED to check the * loaderId, but this is certainly best practice. * * @param loaderId The loader ID for which we need to create a loader * @param bundle Any arguments supplied by the caller * @return A new Loader instance that is ready to start loading. */ @Override public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) { switch (loaderId) { case ID_FORECAST_LOADER: /* URI for all rows of weather data in our weather table */ Uri forecastQueryUri = WeatherContract.WeatherEntry.CONTENT_URI; /* Sort order: Ascending by date */ String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC"; /* * A SELECTION in SQL declares which rows you'd like to return. In our case, we * want all weather data from today onwards that is stored in our weather table. * We created a handy method to do that in our WeatherEntry class. */ String selection = WeatherContract.WeatherEntry.getSqlSelectForTodayOnwards(); return new CursorLoader(this, forecastQueryUri, MAIN_FORECAST_PROJECTION, selection, null, sortOrder); default: throw new RuntimeException("Loader Not Implemented: " + loaderId); } }
Example #27
Source File: FilterFriendsListUselessFragment.java From PADListener with GNU General Public License v2.0 | 5 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { MyLog.entry(); final StringBuilder selectionBuilder = new StringBuilder(); selectionBuilder.append(CapturedPlayerFriendDescriptor.TABLE_NAME).append(".").append(CapturedPlayerFriendLeaderDescriptor.Fields.PLAYER_ID.getColName()); selectionBuilder.append(" NOT IN ("); boolean first = true; for (final Long usefulFriendId : mUsefulFriendIds) { if (!first) { selectionBuilder.append(", "); } selectionBuilder.append(usefulFriendId); first = false; } selectionBuilder.append(")"); if (mOnlyNotFavourite) { selectionBuilder.append(" AND "); selectionBuilder.append(CapturedPlayerFriendDescriptor.TABLE_NAME).append(".").append(CapturedPlayerFriendDescriptor.Fields.FAVOURITE.getColName()); selectionBuilder.append(" = ").append(BaseProviderHelper.BOOLEAN_FALSE); } final Loader<Cursor> loader = new CursorLoader(getActivity(), CapturedPlayerFriendDescriptor.UriHelper.uriForAllWithInfo(), null, selectionBuilder.toString(), null, CapturedPlayerFriendDescriptor.TABLE_NAME + "." + CapturedPlayerFriendDescriptor.Fields.NAME.getColName()); MyLog.exit(); return loader; }
Example #28
Source File: MainActivity.java From android-dev-challenge with Apache License 2.0 | 5 votes |
/** * Called by the {@link android.support.v4.app.LoaderManagerImpl} when a new Loader needs to be * created. This Activity only uses one loader, so we don't necessarily NEED to check the * loaderId, but this is certainly best practice. * * @param loaderId The loader ID for which we need to create a loader * @param bundle Any arguments supplied by the caller * @return A new Loader instance that is ready to start loading. */ @Override public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) { switch (loaderId) { case ID_FORECAST_LOADER: /* URI for all rows of weather data in our weather table */ Uri forecastQueryUri = WeatherContract.WeatherEntry.CONTENT_URI; /* Sort order: Ascending by date */ String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC"; /* * A SELECTION in SQL declares which rows you'd like to return. In our case, we * want all weather data from today onwards that is stored in our weather table. * We created a handy method to do that in our WeatherEntry class. */ String selection = WeatherContract.WeatherEntry.getSqlSelectForTodayOnwards(); return new CursorLoader(this, forecastQueryUri, MAIN_FORECAST_PROJECTION, selection, null, sortOrder); default: throw new RuntimeException("Loader Not Implemented: " + loaderId); } }
Example #29
Source File: ViewLoadable.java From android-atleap with Apache License 2.0 | 5 votes |
/** * Instantiate and return a new Loader for the given ID. * * @param id The ID whose loader is to be created. * @param args Any arguments supplied by the caller. * @return Return a new Loader instance that is ready to start loading. */ @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader(mContext, mUri, mProjection, mSelection, mSelectionArgs, mSortOrder ); }
Example #30
Source File: MainActivity.java From android-dev-challenge with Apache License 2.0 | 5 votes |
/** * Called by the {@link android.support.v4.app.LoaderManagerImpl} when a new Loader needs to be * created. This Activity only uses one loader, so we don't necessarily NEED to check the * loaderId, but this is certainly best practice. * * @param loaderId The loader ID for which we need to create a loader * @param bundle Any arguments supplied by the caller * @return A new Loader instance that is ready to start loading. */ @Override public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) { switch (loaderId) { case ID_FORECAST_LOADER: /* URI for all rows of weather data in our weather table */ Uri forecastQueryUri = WeatherContract.WeatherEntry.CONTENT_URI; /* Sort order: Ascending by date */ String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC"; /* * A SELECTION in SQL declares which rows you'd like to return. In our case, we * want all weather data from today onwards that is stored in our weather table. * We created a handy method to do that in our WeatherEntry class. */ String selection = WeatherContract.WeatherEntry.getSqlSelectForTodayOnwards(); return new CursorLoader(this, forecastQueryUri, MAIN_FORECAST_PROJECTION, selection, null, sortOrder); default: throw new RuntimeException("Loader Not Implemented: " + loaderId); } }