android根据Uri得到图片文件的真实路径
2016-09-18 15:59
543 查看
/** * Try to return the absolute file path from the given Uri * * @param context * @param uri * @return the file path or null */ public static String getRealFilePath( final Context context, final Uri uri ) { if ( null == uri ) return null; final String scheme = uri.getScheme(); String data = null; if ( scheme == null ) data = uri.getPath(); else if ( ContentResolver.SCHEME_FILE.equals( scheme ) ) { data = uri.getPath(); } else if ( ContentResolver.SCHEME_CONTENT.equals( scheme ) ) { Cursor cursor = context.getContentResolver().query( uri, new String[] { ImageColumns.DATA }, null, null, null ); if ( null != cursor ) { if ( cursor.moveToFirst() ) { int index = cursor.getColumnIndex( ImageColumns.DATA ); if ( index > -1 ) { data = cursor.getString( index ); } } cursor.close(); } } return data; }
相关文章推荐
- Android之根据Uri获得图片或视频文件路径(解决4.4以上版本得不到路径的情况)
- Android之根据Uri获得图片或视频文件路径(解决4.4以上版本得不到路径的情况)
- Android之根据Uri获得图片或视频文件路径(解决4.4以上版本得不到路径的情况)
- Android 通过图片Uri得到图片真实路径的
- Android之根据Uri获得图片或视频文件路径(解决4.4以上版本得不到路径的情况)
- Android之根据Uri获得图片或视频文件路径(解决4.4以上版本得不到路径的情况)
- Android之根据Uri获得图片或视频文件路径(解决4.4以上版本得不到路径的情况)
- android根据Uri获取文件路径
- android 根据Uri获取文件绝对路径
- android根据uri或文件绝对路径获取文件基本信息
- Android 获取图库图片 根据uri获取路径
- Android之图片压缩和Uri与String类型的路径转换,获取图片,文件大小的工具类
- Android根据文件路径获取图片的名字
- android根据原图片的路径得到该图片的缩略图
- 一些有关Android图片的操作,判断方向,旋转,根据uri获取绝对路径,缩放与移动
- android图片文件的路径地址与Uri的相互转换
- android图片文件的路径地址与Uri的相互转换
- Android根据Uri获得其在文件系统中的路径
- android图片文件的路径地址与Uri的相互转换
- android 根据uri获取真实路径