저는 자바 (특히 안드로이드)를 다소 새로운 것으로 보았습니다. 나는 사용자가 갤러리에서 이미지를 선택하도록하고, 그 다음에 앱은 갤러리의 이미지를 애플리케이션의 디렉토리에있는 폴더로 복사한다 (이미지 버튼에서 선택한 그림을 표시 할뿐만 아니라). 그러나 "처리되지 않은 예외 유형 IOException"이라는 컴파일러 오류가 발생합니다.자바 - "처리되지 않은 예외 유형 IOException"
이 내 코드입니다 : (어딘가에 이전)
Intent i = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, 2);
(onActivityResult를 함수)
Uri selectedImage = data.getData(); //data from onActivityResult
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();
ImageButton abcd = (ImageButton) findViewById(R.id.btn_addpicture);
abcd.setImageBitmap(BitmapFactory.decodeFile(picturePath));
String command = "cp " + "'" + selectedImage.getPath().toString() + "' '" + getFilesDir().getPath() + "/Images/" + VALUE_NAME + ".jpg";
Runtime.getRuntime().exec(command);
오류가 마지막 줄에서 온다. 아무도 내가 잘못 갔는지 설명 할 수 있습니까? 나는 오류가
http://stackoverflow.com/questions/6115896/java-checked-vs-unchecked-exception-explanation –
일반적인 File 메서드 대신이 메서드를 사용하여 파일을 복사하는 이유가 있습니까? 나는 그것이 아주 좋은 습관이라고 생각하지 않는다. – SimonSays
사실 이것이 XD에 대해 알고있는 유일한 방법이기 때문에 – chesnutcase