안녕하세요,


소개팅 앱을 만들고 있습니다.


다음과 같이 처음에 가입화면에서 프로필 사진을 올리기 위해

createChooser 와 onActivityResult를 통해서 갤러리의 이미지를 고르르는 코드입니다.

 이미지 경로를 불러와서 화면에 보여주는 부분에서 문제가 생깁니다.

특정기기에서만 사진 경로가 잡히지 않는것 같습니다. 이럴경우 어떻게 해결해야 할까요? ㅜㅜ



public String getRealPathFromURI(Uri contentURI) {
Uri contentUri = contentURI;

String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = null;
try {
if (Build.VERSION.SDK_INT > 19) {
// Will return "image:x*"
String wholeID = DocumentsContract.getDocumentId(contentUri);
// Split at colon, use second item in the array
String id = wholeID.split(":")[1];
// where id is equal to
String sel = MediaStore.Images.Media._ID + "=?";

cursor = getApplicationContext().getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
projection, sel, new String[] { id }, null);
} else {
cursor = getApplicationContext().getContentResolver().query(contentUri,
projection, null, null, null);
}
} catch (Exception e) {
e.printStackTrace();
}

String path = null;
try {
int column_index = cursor
.getColumnIndex(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
path = cursor.getString(column_index);
cursor.close();
} catch (Exception e) {
e.printStackTrace();
}
return path;
}
다음과 같은 함수를 사용해서 불러오려고 했으나 G4등의 기기에서는 경로가 잡히는데 특정 기기에서 (넥서스)등에서 경로가 잡히지 않습니다.
모든 기기에 제한없이 정확한 Path를 불러오게 하려면 어떻게 해야 할까요? ㅜㅜ
혹시 저와 같은 문제를 겪으신 분이 있나요??
아시는 분은 도움주시면 정말 잊지 않을게요!!