try { Uri selectedImage = data.getData(); String[] filePathColumn = { MediaStore.Images.Media.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(); imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath)); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); }
轉自http://blog.csdn.net/shaojie519/article/details/7626962