Uri photoUri = data.getData();
String[] pojo = {MediaStore.MediaColumns.DATA}; // The method managedQuery() from the type Activity is deprecated //Cursor cursor = managedQuery(photoUri, pojo, null, null, null); Cursor cursor = getActivity().getContentResolver().query(photoUri, pojo, null, null, null); String _fileName = ""; if(null!=cursor){ cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(pojo[0]); picPath = cursor.getString(columnIndex); cursor.close(); }else if(null!=photoUri){ String tmpPath = photoUri.getPath(); if (tmpPath != null && (tmpPath.endsWith(".jpg") || tmpPath.endsWith(".png") || tmpPath.endsWith(".gif")|| tmpPath.endsWith(".jpeg") )) { picPath = tmpPath; } }