當前位置: 首頁>>代碼示例>>Java>>正文


Java Media.DATA屬性代碼示例

本文整理匯總了Java中android.provider.MediaStore.Images.Media.DATA屬性的典型用法代碼示例。如果您正苦於以下問題:Java Media.DATA屬性的具體用法?Java Media.DATA怎麽用?Java Media.DATA使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.provider.MediaStore.Images.Media的用法示例。


在下文中一共展示了Media.DATA屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildAlbumCover

/**
 * 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};
    Cursor coverCursor = cr.query(Media.EXTERNAL_CONTENT_URI, photoColumn, SELECTION_ID,
            new String[]{buckId, "image/jpeg", "image/png", "image/jpg", "image/gif"}, 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();
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:AlbumTask.java

示例2: getInformationFromMediaDatabase

private boolean getInformationFromMediaDatabase() {
	String[] fields = { Media.DATA, ImageColumns.ORIENTATION };
	Cursor cursor = resolver.query(uri, fields, null, null, null);

	if (cursor == null)
		return false;

	cursor.moveToFirst();
	path = cursor.getString(cursor.getColumnIndex(Media.DATA));
	int orientation = cursor.getInt(cursor.getColumnIndex(ImageColumns.ORIENTATION));
	this.orientation = new Matrix();
	this.orientation.setRotate(orientation);
	cursor.close();

	return true;
}
 
開發者ID:gandulf,項目名稱:DsaTab,代碼行數:16,代碼來源:PhotoPicker.java

示例3: buildAlbumCover

/**
 * 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();
        }
    }
}
 
開發者ID:Bilibili,項目名稱:boxing,代碼行數:33,代碼來源:AlbumTask.java

示例4: getOriginalImagePath

/**
 * 得到原始圖像路徑
 *
 * @param image_id
 * @return 原始圖片路徑
 */
public static String getOriginalImagePath(Context context, String image_id) {
    String path = null;
    String[] projection = {Media._ID, Media.DATA};
    Cursor cursor = context.getContentResolver().query(Media.EXTERNAL_CONTENT_URI, projection,
            Media._ID + "=" + image_id, null, null);
    if (cursor != null) {
        cursor.moveToFirst();
        path = cursor.getString(cursor.getColumnIndex(Media.DATA));
    }

    cursor.close();
    return path;
}
 
開發者ID:gitxuyulin,項目名稱:EditorImageAndText,代碼行數:19,代碼來源:ImagePathUtil.java

示例5: getOriginalImagePath

/**
 * 得到原始圖像路徑
 *
 * @param image_id
 * @return
 */
String getOriginalImagePath(String image_id) {
    String path = null;
    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));
    }
    cursor.close();
    return path;
}
 
開發者ID:gitxuyulin,項目名稱:EditorImageAndText,代碼行數:18,代碼來源:AlbumHelper.java

示例6: buildImagesBucketList

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;
}
 
開發者ID:Dreamer206602,項目名稱:SimplifyReader2,代碼行數:36,代碼來源:ImagePickerHelper.java

示例7: getOriginalImagePath

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;
}
 
開發者ID:androidWeq,項目名稱:ItHome,代碼行數:13,代碼來源:AlbumHelper.java

示例8: getOriginalImagePath

/**
 * �õ�ԭʼͼ��·��
 * 
 * @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;
}
 
開發者ID:linmp4,項目名稱:quickmark,代碼行數:19,代碼來源:AlbumHelper.java

示例9: getOriginalImagePath

public 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;
}
 
開發者ID:CodeDogandCat,項目名稱:CarApp,代碼行數:12,代碼來源:AlbumHelper.java

示例10: getOriginalImagePath

/**
 * 得到原始圖像路徑
 *
 * @param image_id
 * @return
 */
String getOriginalImagePath(String image_id) {
    String path = null;
    String[] projection = { Media._ID, Media.DATA };
    Cursor cursor = resolver.query(Media.EXTERNAL_CONTENT_URI, projection,
            Media._ID + "=" + image_id, null, null);
    if (cursor != null) {
        cursor.moveToFirst();
        path = cursor.getString(cursor.getColumnIndex(Media.DATA));
        cursor.close();
    }
    return path;
}
 
開發者ID:zillachan,項目名稱:LibZilla,代碼行數:18,代碼來源:AlbumHelper.java

示例11: getImageBucket

private void getImageBucket() {
	// 構造縮略圖索引
	getThumbnail();
	// 構造相冊索引
	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 cur = cr.query(Media.EXTERNAL_CONTENT_URI, columns, null, null, "_id DESC");
	if (cur.moveToFirst()) {
		// 獲取指定列的索引
		int photoIDIndex = cur.getColumnIndexOrThrow(Media._ID);
		int photoPathIndex = cur.getColumnIndexOrThrow(Media.DATA);
		int bucketDisplayNameIndex = cur.getColumnIndexOrThrow(Media.BUCKET_DISPLAY_NAME);
		int bucketIdIndex = cur.getColumnIndexOrThrow(Media.BUCKET_ID);
		do {
			String _id = cur.getString(photoIDIndex);
			String path = cur.getString(photoPathIndex);
			String bucketName = cur.getString(bucketDisplayNameIndex);
			String bucketId = cur.getString(bucketIdIndex);
			ImageBucket bucket = bucketList.get(bucketId);
			if (bucket == null) {
				bucket = new ImageBucket();
				bucketList.put(bucketId, bucket);
				bucket.imageList = new ArrayList<ImageItem>();
				bucket.bucketName = bucketName;
			}
			bucket.count++;
			ImageItem imageItem = new ImageItem();
			imageItem.imageId = _id;
			imageItem.imagePath = path;
			imageItem.thumbnailPath = thumbnailList.get(_id);
			imageItem.duration = "00:00";
			bucket.imageList.add(imageItem);
		} while (cur.moveToNext());
	}
}
 
開發者ID:do-android,項目名稱:do_Album,代碼行數:35,代碼來源:AlbumHelper.java

示例12: getOriginalImagePath

/**
 * 得到原始圖像路徑
 * 
 * @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;
}
 
開發者ID:cymcsg,項目名稱:UltimateAndroid,代碼行數:19,代碼來源:AlbumHelper.java

示例13: buildImagesBucketList

public static HashMap<String, ImageBucket> buildImagesBucketList(Context context) {
    ContentResolver cr = context.getContentResolver();
    HashMap<String, ImageBucket> bucketList = new HashMap<String, ImageBucket>();

    // 構造縮略圖索引
    HashMap<String, String> thumbnailList = getThumbnail(cr);

    // 構造相冊索引
    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 cur = cr.query(Media.EXTERNAL_CONTENT_URI, columns, null, null,
            null);
    if (cur.moveToFirst()) {
        // 獲取指定列的索引
        int photoIDIndex = cur.getColumnIndexOrThrow(Media._ID);
        int photoPathIndex = cur.getColumnIndexOrThrow(Media.DATA);
        int bucketDisplayNameIndex = cur
                .getColumnIndexOrThrow(Media.BUCKET_DISPLAY_NAME);
        int bucketIdIndex = cur.getColumnIndexOrThrow(Media.BUCKET_ID);

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

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

        } while (cur.moveToNext());
    }
    cur.close();
    return bucketList;
}
 
開發者ID:gitxuyulin,項目名稱:EditorImageAndText,代碼行數:47,代碼來源:ImagePathUtil.java

示例14: buildImagesBucketList

/**
 * 獲取sd卡中的圖片,並創建圖片文件夾的列表
 */
private void buildImagesBucketList(Context context) {
    File file;
    String[] columns = {Media._ID, Media.BUCKET_ID, Media.DATA, Media.BUCKET_DISPLAY_NAME};
    Cursor cur = context.getContentResolver().query(Media.EXTERNAL_CONTENT_URI, columns, null, null,
            "_id DESC");
    if (cur != null && cur.getCount() <= 0) {
        throw new NullPointerException("do not  find any picture");
    }
    if (cur != null && cur.moveToFirst()) {
        final int photoIdIndex = cur.getColumnIndexOrThrow(Media._ID);
        final int photoPathIndex = cur.getColumnIndexOrThrow(Media.DATA);//圖片路徑字段
        final int bucketDisplayNameIndex = cur.getColumnIndexOrThrow(Media.BUCKET_DISPLAY_NAME);
        final int bucketIdIndex = cur.getColumnIndexOrThrow(Media.BUCKET_ID);
        do {
            int id = cur.getInt(photoIdIndex);
            String path = cur.getString(photoPathIndex);
            int bucketId = cur.getInt(bucketIdIndex);
            String bucketname = cur.getString(bucketDisplayNameIndex);
            file = new File(path);
            if (!file.exists() || file.length() == 0)
                continue;
            ImageItem i = new ImageItem();
            i.imageId = id;
            i.imagePath = path;
            i.imageSize = file.length();
            i.createTime = file.lastModified();
            imageList.add(i);
            ImageBucket bucket;
            if (this.bucketMap.containsKey(bucketId))
                bucket = this.bucketMap.get(bucketId);
            else {
                bucket = new ImageBucket();
                bucketMap.put(bucketId, bucket);
                bucket.bucketName = bucketname;
                bucket.imageList = new ArrayList<>();
            }
            bucket.count++;
            bucket.imageList.add(i);
        } while (cur.moveToNext());
    }
    if (cur != null)
        cur.close();
}
 
開發者ID:cocolove2,項目名稱:LISDemo,代碼行數:46,代碼來源:AlbumHelper.java

示例15: buildImageBucketList

public void buildImageBucketList(){
    //先獲取縮略圖索引
    getThumbnail();
    //查詢獲取相冊索引
    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 = resolver.query(Media.EXTERNAL_CONTENT_URI, columns, null, null,
            Media._ID+" desc");
    if (cursor.moveToFirst()){
        // 獲取指定列的索引
        int photoIDIndex = cursor.getColumnIndexOrThrow(Media._ID);
        int photoPathIndex = cursor.getColumnIndexOrThrow(Media.DATA);
        int photoNameIndex = cursor.getColumnIndexOrThrow(Media.DISPLAY_NAME);
        int photoTitleIndex = cursor.getColumnIndexOrThrow(Media.TITLE);
        int photoSizeIndex = cursor.getColumnIndexOrThrow(Media.SIZE);
        int bucketDisplayNameIndex = cursor
                .getColumnIndexOrThrow(Media.BUCKET_DISPLAY_NAME);
        int bucketIdIndex = cursor.getColumnIndexOrThrow(Media.BUCKET_ID);
        int picasaIdIndex = cursor.getColumnIndexOrThrow(Media.PICASA_ID);
        // 獲取圖片總數
        int totalNum = cursor.getCount();
        do {
            String _id = cursor.getString(photoIDIndex);
            String name = cursor.getString(photoNameIndex);
            String path = cursor.getString(photoPathIndex);
            String title = cursor.getString(photoTitleIndex);
            String size = cursor.getString(photoSizeIndex);
            String bucketName = cursor.getString(bucketDisplayNameIndex);
            String bucketId = cursor.getString(bucketIdIndex);
            String picasaId = cursor.getString(picasaIdIndex);

            ImageBucket bucket = bucketList.get(bucketId);
            if (bucket == null) {
                bucket = new ImageBucket();
                bucketList.put(bucketId, bucket);
                bucket.imageList = new ArrayList<>();
                bucket.bucketName = bucketName;
            }
            bucket.count++;
            ImageItem imageItem = new ImageItem();
            imageItem.imageId = _id;
            imageItem.imagePath = path;
            imageItem.thumbnailPath = thumbnailList.get(_id);
            bucket.imageList.add(imageItem);
        }while (cursor.moveToNext());

    }
    cursor.close();
    hasBuildImagesBucketList = true;
}
 
開發者ID:zillachan,項目名稱:LibZilla,代碼行數:57,代碼來源:AlbumHelper.java


注:本文中的android.provider.MediaStore.Images.Media.DATA屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。