标签:android blog http java os art ar new
Uri uri = data.getData(); String[] proj = { MediaStore.Images.Media.DATA }; Cursor actualimagecursor = managedQuery(uri,proj,null,null,null); int actual_image_column_index = actualimagecursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); actualimagecursor.moveToFirst(); String img_path = actualimagecursor.getString(actual_image_column_index); File file = new File(img_path);
以下是4.2.2之后,managedQuery方法被废弃后的解决方案:
public String getRealPathFromURI(Uri contentUri) {
String res = null;
String[] proj = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(contentUri, proj, null, null, null);
if(cursor.moveToFirst()){;
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
res = cursor.getString(column_index);
}
cursor.close();
return res;
}
http://blog.csdn.net/sp6645597/article/details/20215563
android Uri获取真实路径转换成File的方法,布布扣,bubuko.com
标签:android blog http java os art ar new
原文地址:http://www.cnblogs.com/daishuguang/p/3883858.html