Android将获取到文件的uri转换为字符串的路径

	/**
	 * 将uri转换为字符串
	 */
	public static String UriToString(Uri uri, Activity act) {
		String img_path = null;
		if(uri != null && act != null){
		String path = "";
		String[] proj = { MediaStore.Images.Media.DATA };
		Cursor actualimagecursor = act
				.managedQuery(uri, proj, null, null, null);
		int actual_image_column_index = actualimagecursor
				.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
		actualimagecursor.moveToFirst();
		img_path = actualimagecursor
				.getString(actual_image_column_index);
		}
		return img_path;
	}

你可能感兴趣的:(Android)