android.content.CursorLoader Java Examples

The following examples show how to use android.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: FileHelper.java    From showCaseCordova with Apache License 2.0 6 votes vote down vote up
@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) {
        result = null;
    }
    return result;
}
 
Example #2
Source File: MainFragment.java    From android-auto-call-recorder with MIT License 6 votes vote down vote up
/**
 * create new cursor with specific projection
 *
 * @param id
 * @param args
 * @return
 */
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    String[] projectALL = new String[]{"*"};

    String selection = null;
    if (args != null) {
        String searchRecord = args.getString("SEARCH_KEY");
        if (searchRecord != null && searchRecord.length() > 0) {
            selection = RecordDbContract.RecordItem.COLUMN_NUMBER + " LIKE '%" + searchRecord + "%'";
        }
    }

    String sort = mPreferenceHelper.getSortSelection()
            + mPreferenceHelper.getSortArrange();
    return new CursorLoader(getActivity(), RecordDbContract.CONTENT_URL, projectALL, selection, null, sort);
}
 
Example #3
Source File: FileHelper.java    From reader with MIT License 6 votes vote down vote up
@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) {
        result = null;
    }
    return result;
}
 
Example #4
Source File: LoginActivityA.java    From ans-android-sdk with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example #5
Source File: FeedsFragment.java    From v2ex with Apache License 2.0 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

    int limit = args.getInt("limit");
    int offset = args.getInt("offset");
    String keyword = args.getString("keyword");
    LOGD(TAG, "Feeds limit is: " + limit + ", offset is: " + offset + ", keyword is: " + keyword);
    Uri uri = V2exContract.Feeds.CONTENT_URI.buildUpon().
            appendQueryParameter(V2exContract.QUERY_PARAMETER_LIMIT, String.valueOf(limit)).
            build();
    String selectionClause = null;
    if (keyword != null && !keyword.trim().isEmpty()) {
        selectionClause = "feed_title LIKE '%" + keyword + "%'";
    } else if (!nodeTitle.isEmpty()) {
        selectionClause = "feed_node LIKE '%" + nodeTitle + "%'";
    }
    return new CursorLoader(getActivity(), uri,
            FeedsQuery.PROJECTION, selectionClause, null, V2exContract.Feeds.FEED_LAST_MODIFIED + " DESC");
}
 
Example #6
Source File: LoginActivity.java    From java-unified-sdk with Apache License 2.0 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
  return new CursorLoader(this,
      // Retrieve data rows for the device user's 'profile' contact.
      Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
          ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

      // Select only email addresses.
      ContactsContract.Contacts.Data.MIMETYPE +
          " = ?", new String[]{ContactsContract.CommonDataKinds.Email
      .CONTENT_ITEM_TYPE},

      // Show primary email addresses first. Note that there won't be
      // a primary email address if the user hasn't specified one.
      ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example #7
Source File: NodesFragment.java    From v2ex with Apache License 2.0 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    String selectionClause = null;
    if (args != null) {
        String keyword = args.getString("keyword");

        if (keyword != null && !keyword.trim().isEmpty()) {
            selectionClause = "node_title LIKE '%" + keyword + "%'";
        }
    }
    return new CursorLoader(
            getActivity(),                                     // Context
            V2exContract.Nodes.CONTENT_URI,                    // Table to query
            PROJECTION,                                        // Projection to return
            selectionClause,                                              // No selection clause
            null,                                              // No selection arguments
            V2exContract.Nodes.NODE_ID + " ASC"                // Default sort order
    );
}
 
Example #8
Source File: LoginActivity.java    From Build-an-AI-Startup-with-PyTorch with MIT License 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example #9
Source File: AlbumActivity.java    From AudioAnchor with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    String[] projection = {
            AnchorContract.AudioEntry.TABLE_NAME + "." + AnchorContract.AudioEntry._ID,
            AnchorContract.AudioEntry.TABLE_NAME + "." + AnchorContract.AudioEntry.COLUMN_TITLE,
            AnchorContract.AudioEntry.TABLE_NAME + "." + AnchorContract.AudioEntry.COLUMN_ALBUM,
            AnchorContract.AudioEntry.TABLE_NAME + "." + AnchorContract.AudioEntry.COLUMN_TIME,
            AnchorContract.AudioEntry.TABLE_NAME + "." + AnchorContract.AudioEntry.COLUMN_COMPLETED_TIME,
            AnchorContract.AlbumEntry.TABLE_NAME + "." + AnchorContract.AlbumEntry.COLUMN_TITLE,
            AnchorContract.AlbumEntry.TABLE_NAME + "." + AnchorContract.AlbumEntry.COLUMN_COVER_PATH
    };

    String sel = AnchorContract.AudioEntry.TABLE_NAME + "." + AnchorContract.AudioEntry.COLUMN_ALBUM + "=?";
    String[] selArgs = {Long.toString(mAlbumId)};
    String sortOrder = "CAST(" + AnchorContract.AudioEntry.TABLE_NAME + "." + AnchorContract.AudioEntry.COLUMN_TITLE + " as SIGNED) ASC, LOWER(" + AnchorContract.AudioEntry.TABLE_NAME + "." + AnchorContract.AudioEntry.COLUMN_TITLE + ") ASC";

    return new CursorLoader(this, AnchorContract.AudioEntry.CONTENT_URI_AUDIO_ALBUM, projection, sel, selArgs, sortOrder);
}
 
Example #10
Source File: ExampleLoginActivity.java    From android-auth-manager with Apache License 2.0 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example #11
Source File: LoginActivity.java    From android-test-demo with MIT License 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
                                                                 .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example #12
Source File: VideoLoader.java    From MediaPickerPoject with MIT License 6 votes vote down vote up
@Override
public Loader onCreateLoader(int picker_type, Bundle bundle) {
    String selection = MediaStore.Files.FileColumns.MEDIA_TYPE + "="
            + MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO;

    Uri queryUri = MediaStore.Files.getContentUri("external");
    CursorLoader cursorLoader = new CursorLoader(
            mContext,
            queryUri,
            MEDIA_PROJECTION,
            selection,
            null, // Selection args (none).
            MediaStore.Files.FileColumns.DATE_ADDED + " DESC" // Sort order.
    );
    return cursorLoader;
}
 
Example #13
Source File: MediaLoader.java    From MediaPickerPoject with MIT License 6 votes vote down vote up
@Override
public Loader onCreateLoader(int picker_type, Bundle bundle) {
    String selection = MediaStore.Files.FileColumns.MEDIA_TYPE + "="
            + MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE
            + " OR "
            + MediaStore.Files.FileColumns.MEDIA_TYPE + "="
            + MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO;

    Uri queryUri = MediaStore.Files.getContentUri("external");
    CursorLoader cursorLoader = new CursorLoader(
            mContext,
            queryUri,
            MEDIA_PROJECTION,
            selection,
            null, // Selection args (none).
            MediaStore.Files.FileColumns.DATE_ADDED + " DESC" // Sort order.
    );
    return cursorLoader;
}
 
Example #14
Source File: LoginActivity.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example #15
Source File: Login.java    From programming with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example #16
Source File: LoaderCursor.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
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(Contacts.CONTENT_FILTER_URI,
                Uri.encode(mCurFilter));
    } else {
        baseUri = Contacts.CONTENT_URI;
    }

    // Now create and return a CursorLoader that will take care of
    // creating a Cursor for the data being displayed.
    String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
            + Contacts.HAS_PHONE_NUMBER + "=1) AND ("
            + Contacts.DISPLAY_NAME + " != '' ))";
    return new CursorLoader(getActivity(), baseUri,
            CONTACTS_SUMMARY_PROJECTION, select, null,
            Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
}
 
Example #17
Source File: LoginActivity.java    From AndroidProjects with MIT License 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example #18
Source File: LoginActivity.java    From foodie-app with Apache License 2.0 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example #19
Source File: Utils.java    From Alexei with Apache License 2.0 6 votes vote down vote up
public String getRealPathFromURI(Context context, Uri contentUri) {
    String[] proj = { MediaStore.Images.Media.DATA };

    //This method was deprecated in API level 11
    //Cursor cursor = managedQuery(contentUri, proj, null, null, null);

    CursorLoader cursorLoader = new CursorLoader(
            context,
            contentUri, proj, null, null, null);
    Cursor cursor = cursorLoader.loadInBackground();

    int column_index =
            cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    return cursor.getString(column_index);
}
 
Example #20
Source File: LoginActivity.java    From journaldev with MIT License 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example #21
Source File: FileHelper.java    From reader with MIT License 6 votes vote down vote up
@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) {
        result = null;
    }
    return result;
}
 
Example #22
Source File: CursorFragment.java    From V.FlyoutTest with MIT License 6 votes vote down vote up
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(Contacts.CONTENT_FILTER_URI,
                Uri.encode(mCurFilter));
    } else {
        baseUri = Contacts.CONTENT_URI;
    }

    // Now create and return a CursorLoader that will take care of
    // creating a Cursor for the data being displayed.
    String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
            + Contacts.HAS_PHONE_NUMBER + "=1) AND ("
            + Contacts.DISPLAY_NAME + " != '' ))";
    return new CursorLoader(getActivity(), baseUri,
            CONTACTS_SUMMARY_PROJECTION, select, null,
            Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
}
 
Example #23
Source File: FileUtil.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 把uri转为File对象
 *
 * @param activity Activity
 * @param uri      文件Uri
 * @return File对象
 */
public static File uri2File(Activity activity, Uri uri) {
    if (Build.VERSION.SDK_INT < 11) {
        // 在API11以下可以使用:managedQuery
        String[] proj = {MediaStore.Images.Media.DATA};
        @SuppressWarnings("deprecation")
        Cursor actualimagecursor = activity.managedQuery(uri, proj, null, null,
                null);
        int actual_image_column_index = actualimagecursor
                .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        actualimagecursor.moveToFirst();
        String img_path = actualimagecursor
                .getString(actual_image_column_index);
        return new File(img_path);
    } else {
        // 在API11以上:要转为使用CursorLoader,并使用loadInBackground来返回
        String[] projection = {MediaStore.Images.Media.DATA};
        CursorLoader loader = new CursorLoader(activity, uri, projection, null,
                null, null);
        Cursor cursor = loader.loadInBackground();
        int column_index = cursor
                .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        cursor.moveToFirst();
        return new File(cursor.getString(column_index));
    }
}
 
Example #24
Source File: FileUtils.java    From VideoMeeting with Apache License 2.0 6 votes vote down vote up
/**
 * 把媒体文件uri转为File对象
 */
public static File uri2File(Activity aty, Uri uri) {
    if (android.os.Build.VERSION.SDK_INT < 11) {
        // 在API11以下可以使用:managedQuery
        String[] proj = { MediaStore.Images.Media.DATA };
        @SuppressWarnings("deprecation")
        Cursor actualimagecursor = aty.managedQuery(uri, proj, null, null,
                null);
        int actual_image_column_index = actualimagecursor
                .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        actualimagecursor.moveToFirst();
        String img_path = actualimagecursor
                .getString(actual_image_column_index);
        return new File(img_path);
    } else {
        // 在API11以上:要转为使用CursorLoader,并使用loadInBackground来返回
        String[] projection = { MediaStore.Images.Media.DATA };
        CursorLoader loader = new CursorLoader(aty, uri, projection, null,
                null, null);
        Cursor cursor = loader.loadInBackground();
        int column_index = cursor
                .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        cursor.moveToFirst();
        return new File(cursor.getString(column_index));
    }
}
 
Example #25
Source File: LoginActivity.java    From Pioneer with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example #26
Source File: ChatterBoxLogin.java    From pubnub-android-chat with MIT License 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example #27
Source File: UserPhotosFragment.java    From android-open-project-demo with Apache License 2.0 6 votes vote down vote up
public Loader<Cursor> onCreateLoader(final int id, Bundle bundle) {

		CursorLoader cursorLoader = null;

		switch (id) {
		case LOADER_USER_PHOTOS_EXTERNAL:
			String selection = null;
			String[] selectionArgs = null;

			if (null != bundle
					&& bundle.containsKey(LOADER_PHOTOS_BUCKETS_PARAM)) {
				selection = Images.Media.BUCKET_ID + " = ?";
				selectionArgs = new String[] { bundle
						.getString(LOADER_PHOTOS_BUCKETS_PARAM) };
			}

			cursorLoader = new PhotupCursorLoader(getActivity(),
					MediaStoreCursorHelper.MEDIA_STORE_CONTENT_URI,
					MediaStoreCursorHelper.PHOTOS_PROJECTION, selection,
					selectionArgs, MediaStoreCursorHelper.PHOTOS_ORDER_BY,
					false);
			break;
		}

		return cursorLoader;
	}
 
Example #28
Source File: LoginActivityB.java    From ans-android-sdk with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example #29
Source File: SessionManagerActivity.java    From sniffer154 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
	Uri uri = PacketContentProvider.SESSIONS_URI;
	CursorLoader cursorLoader = new CursorLoader(
			SessionManagerActivity.this, uri, null, null, null,
			SessionTable.C_SESSION_DATE + " DESC");
	Log.d(TAG, "onCreateLoader()");
	return cursorLoader;
}
 
Example #30
Source File: DisplayActivity.java    From coursera-android with MIT License 5 votes vote down vote up
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

        String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
                + Contacts.DISPLAY_NAME + " != '' ) AND (" + Contacts.STARRED
                + "== 1))";

        return new CursorLoader(this, Contacts.CONTENT_URI, columnsToExtract,
                select, null, Contacts._ID + " ASC");
    }