当前位置: 首页>>代码示例>>Java>>正文


Java MediaColumns.DATA属性代码示例

本文整理汇总了Java中android.provider.MediaStore.MediaColumns.DATA属性的典型用法代码示例。如果您正苦于以下问题:Java MediaColumns.DATA属性的具体用法?Java MediaColumns.DATA怎么用?Java MediaColumns.DATA使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.provider.MediaStore.MediaColumns的用法示例。


在下文中一共展示了MediaColumns.DATA属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDataColumn

private String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {  
    Cursor cursor = null;  
    String[] column = {MediaColumns.DATA};  
  
    try {  
        cursor = context.getContentResolver().query(uri, column, selection, selectionArgs, null);  
        if (cursor != null && cursor.moveToFirst()) {  
            final int index = cursor.getColumnIndexOrThrow(column[0]);  
            return cursor.getString(index);  
        }  
    } catch (Exception e) {
		Log.e("getRealPath error ", "exception: " + e);
    } finally {  
        if (cursor != null)  
            cursor.close();  
    }  
    return null;  
}
 
开发者ID:lbbniu,项目名称:CCDownload,代码行数:18,代码来源:UploadFragment.java

示例2: move

public boolean move(File srcFile, File targetFile) {
    boolean res = srcFile.renameTo(targetFile);
    if (res) {
        // Add the new file to the medialib
        scanFile(targetFile);

        // Remove the source file from the medialib
        //            scanFile(srcFile);
        ContentResolver cr = context.getContentResolver();
        Uri uri = MediaStore.Files.getContentUri("external");
        String where = MediaColumns.DATA + "=?";
        String[] selectionArgs = { srcFile.getPath() };
        cr.delete(uri, where, selectionArgs);
    }
    return res;
}
 
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:16,代码来源:FileManagerCore.java

示例3: getUriImagePathQuery

/**
 * 获取媒体数据库路径 . <br>
 * @author liulongzhenhai 2012-8-1 下午5:09:27 <br>
 * @param ct 上下文
 * @param contentUri URI地址
 * @return 返回相应的绝对路径
 */
public static String getUriImagePathQuery(final Context ct, final Uri contentUri) {
	// can post image
	if (contentUri == null) {
		return "";
	}

	final String[] proj = { MediaColumns.DATA };
	String path = "";
	final Cursor cursor = ct.getContentResolver().query(contentUri, proj, null, null, null);
	if (cursor != null) {
		if (cursor.moveToFirst()) {
			path = cursor.getString(cursor.getColumnIndexOrThrow(MediaColumns.DATA));
		}
		cursor.close();
	}
	return path;
}
 
开发者ID:VK2012,项目名称:AppCommonFrame,代码行数:24,代码来源:BitmapUtil.java

示例4: getImagePath

/**
 * 获取图片路径 2014年8月12日
 *
 * @param uri
 * @return E-mail:[email protected]
 */
public static String getImagePath(Uri uri, Activity context) {

    String[] projection = {MediaColumns.DATA};
    Cursor cursor = context.getContentResolver().query(uri, projection,
            null, null, null);
    if (cursor != null) {
        cursor.moveToFirst();
        int columIndex = cursor.getColumnIndexOrThrow(MediaColumns.DATA);
        String ImagePath = cursor.getString(columIndex);
        cursor.close();
        return ImagePath;
    }

    return uri.toString().replace("file://", "");
}
 
开发者ID:giantss,项目名称:com.giants.multiimagespicker,代码行数:21,代码来源:ImageUtils.java

示例5: getDataColumn

public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
	Cursor cursor = null;
	final String column = MediaColumns.DATA;
	final String[] projection = { column };
	try {
		cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
		if (cursor != null && cursor.moveToFirst()) {
			final int index = cursor.getColumnIndexOrThrow(column);
			return cursor.getString(index);
		}
	} finally {
		if (cursor != null)
			cursor.close();
	}
	return null;
}
 
开发者ID:Revival-liangjialiang,项目名称:ShoppingApp,代码行数:16,代码来源:DocumentUtil.java

示例6: getImagePath

/**
 * 获取图片路径 2014年8月12日
 *
 * @param uri
 * @param context
 * @return E-mail:[email protected]
 */
public static String getImagePath(Uri uri, Activity context) {

    String[] projection = { MediaColumns.DATA };
    Cursor cursor = context.getContentResolver().query(uri, projection,
            null, null, null);
    if (cursor != null) {
        cursor.moveToFirst();
        int columIndex = cursor.getColumnIndexOrThrow(MediaColumns.DATA);
        String ImagePath = cursor.getString(columIndex);
        cursor.close();
        return ImagePath;
    }

    return uri.toString();
}
 
开发者ID:shenhuniurou,项目名称:WheelViewPicker,代码行数:22,代码来源:ImageUtils.java

示例7: deleteFile

public synchronized static boolean deleteFile(Context context, String path) {
	File file = new File(path);
	boolean issucc = false;
	if (file.exists()) {
		issucc = file.delete();
		if (issucc) {
			String where = MediaColumns.DATA + "=?";
			String[] selectionArgs = new String[] { path };
			int columnsNum = context.getContentResolver()
					.delete(Images.Media.EXTERNAL_CONTENT_URI, where,
							selectionArgs);
			if (columnsNum > 0) {
				return issucc;
			} else {
				return false;
			}
		} else {
			return false;
		}

	} else {
		return false;
	}

}
 
开发者ID:hubert1002,项目名称:WiCamera3D,代码行数:25,代码来源:OperationFile.java

示例8: getImagePath

/**
 * 获取图片路径 2014年8月12日
 * 
 * @param uri
 * @param cursor
 * @return E-mail:[email protected]
 */
public static String getImagePath(Uri uri, Activity context) {

    String[] projection = { MediaColumns.DATA };
    Cursor cursor = context.getContentResolver().query(uri, projection,
            null, null, null);
    if (cursor != null) {
        cursor.moveToFirst();
        int columIndex = cursor.getColumnIndexOrThrow(MediaColumns.DATA);
        String ImagePath = cursor.getString(columIndex);
        cursor.close();
        return ImagePath;
    }

    return uri.toString();
}
 
开发者ID:haiyangxue,项目名称:blogplu,代码行数:22,代码来源:ImageUtils.java

示例9: getDataColumn

private static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
    Cursor cursor = null;
    final String column = MediaColumns.DATA;
    final String[] projection = { column };

    try {
        cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
        if (cursor != null && cursor.moveToFirst()) {
            final int column_index = cursor.getColumnIndexOrThrow(column);
            return cursor.getString(column_index);
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
    return null;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:18,代码来源:UriFileUtils.java

示例10: onActivityResult

/** Resolves the path of the image that was picked. */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	super.onActivityResult(requestCode, resultCode, data);
	if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
		Uri selectedImage = data.getData();
		String[] filePathColumn = { MediaColumns.DATA };
		Cursor cursor = getContentResolver().query(selectedImage,
				filePathColumn, null, null, null);
		cursor.moveToFirst();
		int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
		String picturePath = cursor.getString(columnIndex);
		cursor.close();
		picturePath2 = picturePath;
		new LongOperation().execute("");
	}
}
 
开发者ID:F4b1-,项目名称:Pixtern-Library,代码行数:17,代码来源:CardValidationActivity.java

示例11: onActivityResult

/** Receives the path of the uploaded image and starts the background thread for Validation**/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	super.onActivityResult(requestCode, resultCode, data);
	//	 initializeOpenCVDependencies();
	if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
		Uri selectedImage = data.getData();
		String[] filePathColumn = { MediaColumns.DATA };
		Cursor cursor = getContentResolver().query(selectedImage,
				filePathColumn, null, null, null);
		cursor.moveToFirst();
		int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
		picturePath = cursor.getString(columnIndex);
		cursor.close();
		picturePath2 = picturePath;

		new LongOperation().execute("");
	}
}
 
开发者ID:F4b1-,项目名称:Pixtern-Library,代码行数:19,代码来源:ValidateUploadActivity.java

示例12: getImagePath

/**
 * 获取图片路径 2014年8月12日
 * 
 * @param uri
 * @param cursor
 * @return E-mail:[email protected]
 */
public static String getImagePath(Uri uri, Activity context) {

	String[] projection = { MediaColumns.DATA };
	Cursor cursor = context.getContentResolver().query(uri, projection,
			null, null, null);
	if (cursor != null) {
		cursor.moveToFirst();
		int columIndex = cursor.getColumnIndexOrThrow(MediaColumns.DATA);
		String ImagePath = cursor.getString(columIndex);
		cursor.close();
		return ImagePath;
	}

	return uri.toString();
}
 
开发者ID:blueelwang,项目名称:oschina-app,代码行数:22,代码来源:ImageUtils.java

示例13: getRealPathFromURI

public static String getRealPathFromURI(Activity context, Uri contentUri) {
	if (context != null && contentUri != null) {
		String[] proj = { MediaColumns.DATA };
		Cursor cursor = context.getContentResolver().query(contentUri,
				proj, null, null, null);
		int s = contentUri.getPath().indexOf("http");
		if (s > -1) {
			return contentUri.getPath().substring(s,
					contentUri.getPath().length());
		} else if (cursor != null) {
			cursor.moveToFirst();
			int column_index = cursor
					.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
			return cursor.getString(column_index);
		} else {
			// Utils.debug("AiOut","cursor null",3);
			return contentUri.toString().replace("file://", "");
		}
	} else {
		return "";
	}
}
 
开发者ID:devonEdison,项目名称:videoMerge,代码行数:22,代码来源:WorkFragment.java

示例14: getFileUriFromContentUri

/**
 * Given an Uri that is a content Uri (e.g.
 * content://media/external/images/media/1884) this function returns the
 * respective file Uri, that is e.g. file://media/external/DCIM/abc.jpg
 * 
 * @param cameraPicUri
 * @return Uri
 */
private Uri getFileUriFromContentUri(Uri cameraPicUri) {
	try {
		if (cameraPicUri != null
				&& cameraPicUri.toString().startsWith("content")) {
			String[] proj = { MediaColumns.DATA };
			Cursor cursor = getContentResolver().query(cameraPicUri, proj, null, null, null);
			cursor.moveToFirst();
			// This will actually give you the file path location of the image.
			String largeImagePath = cursor.getString(cursor
											.getColumnIndexOrThrow(MediaColumns.DATA));
			return Uri.fromFile(new File(largeImagePath));
		}
		return cameraPicUri;
	} catch (Exception e) {
		return cameraPicUri;
	}
}
 
开发者ID:theelookdeveloper,项目名称:CodePix-Android,代码行数:25,代码来源:CameraIntentHelperActivity.java

示例15: fileToContentUri

/**
 * Method that converts a file reference to a content uri reference
 *
 * @param cr A content resolver
 * @param path The path to search
 * @param volume The volume
 * @return Uri The content uri or null if file not exists in the media database
 */
private static Uri fileToContentUri(ContentResolver cr, String path, String volume) {
    final String[] projection = {BaseColumns._ID, MediaStore.Files.FileColumns.MEDIA_TYPE};
    final String where = MediaColumns.DATA + " = ?";
    Uri baseUri = MediaStore.Files.getContentUri(volume);
    Cursor c = cr.query(baseUri, projection, where, new String[]{path}, null);
    try {
        if (c != null && c.moveToNext()) {
            int type = c.getInt(c.getColumnIndexOrThrow(
                    MediaStore.Files.FileColumns.MEDIA_TYPE));
            if (type != 0) {
                // Do not force to use content uri for no media files
                long id = c.getLong(c.getColumnIndexOrThrow(BaseColumns._ID));
                return Uri.withAppendedPath(baseUri, String.valueOf(id));
            }
        }
    } finally {
        IOUtils.closeQuietly(c);
    }
    return null;
}
 
开发者ID:Doctoror,项目名称:Pure-File-Manager,代码行数:28,代码来源:MediaHelper.java


注:本文中的android.provider.MediaStore.MediaColumns.DATA属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。