Java Code Examples for android.provider.MediaStore.Images.Media#DATA

The following examples show how to use android.provider.MediaStore.Images.Media#DATA . 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: AlbumTask.java    From boxing with Apache License 2.0 5 votes vote down vote up
/**
 * get the cover and count
 *
 * @param buckId album id
 */
private void buildAlbumCover(ContentResolver cr, String buckId, AlbumEntity album) {
    String[] photoColumn = new String[]{Media._ID, Media.DATA};
    boolean isNeedGif = mPickerConfig != null && mPickerConfig.isNeedGif();
    String selectionId = isNeedGif ? SELECTION_ID : SELECTION_ID_WITHOUT_GIF;
    String[] args = isNeedGif ? SELECTION_ARGS_IMAGE_MIME_TYPE : SELECTION_ARGS_IMAGE_MIME_TYPE_WITHOUT_GIF;
    String[] selectionArgs = new String[args.length + 1];
    selectionArgs[0] = buckId;
    for (int i = 1; i < selectionArgs.length; i++) {
        selectionArgs[i] = args[i-1];
    }
    Cursor coverCursor = cr.query(Media.EXTERNAL_CONTENT_URI, photoColumn, selectionId,
            selectionArgs, Media.DATE_MODIFIED + " desc");
    try {
        if (coverCursor != null && coverCursor.moveToFirst()) {
            String picPath = coverCursor.getString(coverCursor.getColumnIndex(Media.DATA));
            String id = coverCursor.getString(coverCursor.getColumnIndex(Media._ID));
            album.mCount = coverCursor.getCount();
            album.mImageList.add(new ImageMedia(id, picPath));
            if (album.mImageList.size() > 0) {
                mBucketMap.put(buckId, album);
            }
        }
    } finally {
        if (coverCursor != null) {
            coverCursor.close();
        }
    }
}
 
Example 2
Source File: ImagePickerHelper.java    From SimplifyReader with Apache License 2.0 5 votes vote down vote up
private void buildImagesBucketList() {
	getThumbnail();
	mBucketList.clear();

	String columns[] = new String[] { Media._ID, Media.BUCKET_ID, Media.PICASA_ID, Media.DATA, Media.DISPLAY_NAME, Media.TITLE, Media.SIZE, Media.BUCKET_DISPLAY_NAME };
	Cursor cursor = contentResolver.query(Media.EXTERNAL_CONTENT_URI, columns, null, null, null);
	if (cursor.moveToFirst()) {
		int photoIDIndex = cursor.getColumnIndexOrThrow(Media._ID);
		int photoPathIndex = cursor.getColumnIndexOrThrow(Media.DATA);
		int bucketDisplayNameIndex = cursor.getColumnIndexOrThrow(Media.BUCKET_DISPLAY_NAME);
		int bucketIdIndex = cursor.getColumnIndexOrThrow(Media.BUCKET_ID);

		do {
			String _id = cursor.getString(photoIDIndex);
			String path = cursor.getString(photoPathIndex);
			String bucketName = cursor.getString(bucketDisplayNameIndex);
			String bucketId = cursor.getString(bucketIdIndex);

			ImageBucket bucket = mBucketList.get(bucketId);
			if (bucket == null) {
				bucket = new ImageBucket();
				mBucketList.put(bucketId, bucket);
				bucket.bucketList = new ArrayList<ImageItem>();
				bucket.bucketName = bucketName;
			}
			bucket.count++;
			ImageItem imageItem = new ImageItem();
			imageItem.setImageId(_id);
			imageItem.setImagePath(path);
			imageItem.setThumbnailPath(mThumbnailList.get(_id));
			bucket.bucketList.add(imageItem);

		} while (cursor.moveToNext());
	}
	hasBuildImagesBucketList = true;
}
 
Example 3
Source File: AlbumHelper.java    From quickmark with MIT License 5 votes vote down vote up
/**
 * �õ�ԭʼͼ��·��
 * 
 * @param image_id
 * @return
 */
String getOriginalImagePath(String image_id) {
	String path = null;
	Log.i(TAG, "---(^o^)----" + image_id);
	String[] projection = { Media._ID, Media.DATA };
	Cursor cursor = cr.query(Media.EXTERNAL_CONTENT_URI, projection,
			Media._ID + "=" + image_id, null, null);
	if (cursor != null) {
		cursor.moveToFirst();
		path = cursor.getString(cursor.getColumnIndex(Media.DATA));

	}
	return path;
}
 
Example 4
Source File: AlbumHelper.java    From school_shop with MIT License 5 votes vote down vote up
String getOriginalImagePath(String image_id) {
	String path = null;
	Log.i(TAG, "---(^o^)----" + image_id);
	String[] projection = { Media._ID, Media.DATA };
	Cursor cursor = cr.query(Media.EXTERNAL_CONTENT_URI, projection,
			Media._ID + "=" + image_id, null, null);
	if (cursor != null) {
		cursor.moveToFirst();
		path = cursor.getString(cursor.getColumnIndex(Media.DATA));

	}
	return path;
}
 
Example 5
Source File: AlbumHelper.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * 得到原始图像路径
 * 
 * @param image_id
 * @return
 */
String getOriginalImagePath(String image_id) {
	String path = null;
	Log.i(TAG, "---(^o^)----" + image_id);
	String[] projection = { Media._ID, Media.DATA };
	Cursor cursor = cr.query(Media.EXTERNAL_CONTENT_URI, projection,
			Media._ID + "=" + image_id, null, null);
	if (cursor != null) {
		cursor.moveToFirst();
		path = cursor.getString(cursor.getColumnIndex(Media.DATA));

	}
	return path;
}