本文整理汇总了Java中android.support.v4.content.CursorLoader类的典型用法代码示例。如果您正苦于以下问题:Java CursorLoader类的具体用法?Java CursorLoader怎么用?Java CursorLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CursorLoader类属于android.support.v4.content包,在下文中一共展示了CursorLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateLoader
import android.support.v4.content.CursorLoader; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
String[] projectionFields = new String[]{
ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.PHOTO_URI
};
CursorLoader cursorLoader = new CursorLoader(MainActivity.this,
ContactsContract.Contacts.CONTENT_URI,
projectionFields,
null,
null,
null);
return cursorLoader;
}
示例2: onCreateLoader
import android.support.v4.content.CursorLoader; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
Uri uri;
switch (id) {
case LOADER_CAN_UPDATE:
uri = AppProvider.getCanUpdateUri();
break;
case LOADER_KNOWN_VULN:
uri = AppProvider.getInstalledWithKnownVulnsUri();
break;
default:
throw new IllegalStateException("Unknown loader requested: " + id);
}
return new CursorLoader(
activity, uri, Schema.AppMetadataTable.Cols.ALL, null, null, Schema.AppMetadataTable.Cols.NAME);
}
示例3: onCreateLoader
import android.support.v4.content.CursorLoader; //导入依赖的package包/类
@Override
public CursorLoader onCreateLoader(int id, Bundle args) {
Uri uri;
if (TextUtils.isEmpty(currentFilterString)) {
uri = InstalledAppProvider.getContentUri();
} else {
uri = InstalledAppProvider.getSearchUri(currentFilterString);
}
return new CursorLoader(
getActivity(),
uri,
InstalledAppTable.Cols.ALL,
null,
null,
InstalledAppTable.Cols.APPLICATION_LABEL);
}
示例4: onCreateLoader
import android.support.v4.content.CursorLoader; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
//checking on rotate
if (mAttachedFragment != null && mAttachedFragment.getActivity() != null) {
if (favflag == 0) {
return new CursorLoader(mAttachedFragment.getActivity(), NewsProvider.MyNews.CONTENT_URI,
null,
null,
null,
null);
} else {
if (favflag == 1) {
return new CursorLoader(mAttachedFragment.getActivity(), NewsProvider.NewsFavourite.CONTENT_URI_FAVOURITE,
null,
null,
null,
null);
}
}
}
return null;
}
示例5: onCreateLoader
import android.support.v4.content.CursorLoader; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
String selection = "";
if (mOnlyWithPhoneNumbers) {
selection = ContactsContract.Contacts.HAS_PHONE_NUMBER;
}
switch (id) {
case CONTACTS_LOADER_ID:
return new CursorLoader(this, CONTACTS_URI, CONTACTS_PROJECTION,
selection, null, CONTACTS_SORT);
case CONTACT_DETAILS_LOADER_ID:
return new CursorLoader(this, CONTACT_DETAILS_URI, CONTACT_DETAILS_PROJECTION,
selection, null, null);
case GROUPS_LOADER_ID:
return new CursorLoader(this, GROUPS_URI, GROUPS_PROJECTION, GROUPS_SELECTION, null, GROUPS_SORT);
}
return null;
}
示例6: onCreateLoader
import android.support.v4.content.CursorLoader; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
CursorLoader loader = new CursorLoader(getContext());
loader.setUri(ChuckContentProvider.TRANSACTION_URI);
if (!TextUtils.isEmpty(currentFilter)) {
if (TextUtils.isDigitsOnly(currentFilter)) {
loader.setSelection("responseCode LIKE ?");
loader.setSelectionArgs(new String[]{ currentFilter + "%" });
} else {
loader.setSelection("path LIKE ?");
loader.setSelectionArgs(new String[]{ "%" + currentFilter + "%" });
}
}
loader.setProjection(HttpTransaction.PARTIAL_PROJECTION);
loader.setSortOrder("requestDate DESC");
return loader;
}
示例7: getRealPathBelowVersion
import android.support.v4.content.CursorLoader; //导入依赖的package包/类
private static String getRealPathBelowVersion(Context context, Uri uri) {
String filePath = null;
LogUtils.i(TAG, "method -> getRealPathBelowVersion " + uri + " path:" + uri.getPath() + " getAuthority:" + uri.getAuthority());
String[] projection = {MediaStore.Images.Media.DATA};
CursorLoader loader = new CursorLoader(context, uri, projection, null,
null, null);
Cursor cursor = loader.loadInBackground();
if (cursor != null) {
cursor.moveToFirst();
filePath = cursor.getString(cursor.getColumnIndex(projection[0]));
cursor.close();
}
if (filePath == null) {
filePath = uri.getPath();
}
return filePath;
}
示例8: onCreateLoader
import android.support.v4.content.CursorLoader; //导入依赖的package包/类
/**
* 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);
}
}
示例9: getRealPathFromURI_API11to18
import android.support.v4.content.CursorLoader; //导入依赖的package包/类
@SuppressLint("NewApi")
public static String getRealPathFromURI_API11to18(Context context, Uri contentUri) {
String[] proj = { MediaStore.Images.Media.DATA };
String result = null;
try {
CursorLoader cursorLoader = new CursorLoader(context, contentUri, proj, null, null, null);
Cursor cursor = cursorLoader.loadInBackground();
if (cursor != null) {
int column_index =
cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
result = cursor.getString(column_index);
}
}
catch (Exception e){
e.printStackTrace();
}
return result;
}
示例10: onCreateLoader
import android.support.v4.content.CursorLoader; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) {
switch (loaderId) {
case ID_FORECAST_LOADER:
Uri forecastQueryUri = WeatherContract.WeatherEntry.CONTENT_URI;
String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
String selection = WeatherContract.WeatherEntry.getSqlSelectForTodayOnwards();
return new CursorLoader(this,
forecastQueryUri,
MAIN_FORECAST_PROJECTION,
selection,
null,
sortOrder);
default:
throw new RuntimeException("Loader Not Implemented: " + loaderId);
}
}
示例11: newInstance
import android.support.v4.content.CursorLoader; //导入依赖的package包/类
public static CursorLoader newInstance(Context context, Album album, boolean capture) {
if (album.isAll()) {
return new AlbumMediaLoader(
context,
QUERY_URI,
PROJECTION,
SELECTION_ALL,
SELECTION_ALL_ARGS,
ORDER_BY,
capture);
} else {
return new AlbumMediaLoader(
context,
QUERY_URI,
PROJECTION,
SELECTION_ALBUM,
getSelectionAlbumArgs(album.getId()),
ORDER_BY,
false);
}
}
示例12: onCreateLoader
import android.support.v4.content.CursorLoader; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
String[] projection = {
PlantEntry._ID,
PlantEntry.COLUMN_NAME,
PlantEntry.COLUMN_PRICE,
PlantEntry.COLUMN_CART_QUANTITY
};
String selection = PlantEntry.COLUMN_CART_QUANTITY + " > 0";
return new CursorLoader(this,
PlantEntry.CONTENT_URI,
projection,
selection,
null,
null);
}
示例13: onCreateLoader
import android.support.v4.content.CursorLoader; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
String[] projection = {
PlantEntry._ID,
PlantEntry.COLUMN_NAME,
PlantEntry.COLUMN_DESCRIPTION,
PlantEntry.COLUMN_PRICE
};
String selection = PlantEntry._ID + " = " + mItemId;
return new CursorLoader(this,
PlantEntry.CONTENT_URI,
projection,
selection,
null,
null);
}
示例14: onCreateLoader
import android.support.v4.content.CursorLoader; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
// This is called when a new Loader needs to be created. This
// fragment only uses one loader, so we don't care about checking the id.
// To only show current and future dates, filter the query to return weather only for
// dates after or including today.
// Sort order: Ascending, by date.
String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
String locationSetting = Utility.getPreferredLocation(getActivity());
Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(
locationSetting, System.currentTimeMillis());
return new CursorLoader(getActivity(),
weatherForLocationUri,
FORECAST_COLUMNS,
null,
null,
sortOrder);
}
示例15: onCreateLoader
import android.support.v4.content.CursorLoader; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
if (id == CHANNELS_LOADER) {
return new CursorLoader(
getActivity(),
ChannelEntry.CONTENT_URI,
CHANNEL_COLUMNS,
TextUtils.isEmpty(category) ? null
: ChannelEntry.TABLE_NAME + "."
+ ChannelEntry.COLUMN_CHANNEL_CATEGORY_ID + " = ?",
TextUtils.isEmpty(category) ? null :
new String[]{String.valueOf(category)},
Utility.getPrefSortChannelOrder(sortBy));
}
return null;
}