Source:
<code>public void setBinaryData(Object binaryuri) { String binaryPath; try { binaryPath = getBinaryPathWithSizeCheck(binaryuri); } catch (IOException e) { e.printStackTrace(); showToast("form.attachment.copy.fail"); Logger.exception(LogTypes.TYPE_MAINTENANCE, e); return; } if (binaryPath == null) { if (!destMediaPath.isEmpty()) { new File(destMediaPath).delete(); } return; } File newMedia; if (!destMediaPath.isEmpty()) { newMedia = new File(destMediaPath); } else { recordedFileName = FileUtil.getFileName(binaryPath); <START> destMediaPath = mInstanceFolder + System.currentTimeMillis() + customFileTag + "." + FileUtil.getExtension(binaryPath); <END> File source = new File(binaryPath); newMedia = new File(destMediaPath); try { FileUtil.copyFile(source, newMedia); } catch (IOException e) { showToast("form.attachment.copy.fail"); Logger.exception(LogTypes.TYPE_MAINTENANCE, e); e.printStackTrace(); } } if (newMedia.exists()) { ContentValues values = new ContentValues(6); values.put(MediaStore.Audio.Media.TITLE, newMedia.getName()); values.put(MediaStore.Audio.Media.DISPLAY_NAME, newMedia.getName()); values.put(MediaStore.Audio.Media.DATE_ADDED, System.currentTimeMillis()); values.put(MediaStore.Audio.Media.DATA, newMedia.getAbsolutePath()); Uri mediaUri = getContext().getContentResolver().insert(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, values); String mediaUriString = mediaUri == null ? "null" : mediaUri.toString(); Log.i(TAG, "Inserting media returned uri = " + mediaUriString); showToast("form.attachment.success"); } else { Log.e(TAG, "Inserting media file FAILED"); } mBinaryName = newMedia.getName(); }</code><technical_language>@wpride FileUtil return a blank extension if path one, result in files something. add dot if extension is added a non-blank value</technical_language>

Target:
public void setBinaryData(Object binaryuri) { String binaryPath; try { binaryPath = getBinaryPathWithSizeCheck(binaryuri); } catch (IOException e) { e.printStackTrace(); showToast("form.attachment.copy.fail"); Logger.exception(LogTypes.TYPE_MAINTENANCE, e); return; } if (binaryPath == null) { if (!destMediaPath.isEmpty()) { new File(destMediaPath).delete(); } return; } File newMedia; if (!destMediaPath.isEmpty()) { newMedia = new File(destMediaPath); } else { recordedFileName = FileUtil.getFileName(binaryPath); String extension = FileUtil.getExtension(binaryPath); if (!FormUploadUtil.isSupportedMultimediaFile(extension)) { Toast.makeText(getContext(), Localization.get("form.attachment.invalid"), Toast.LENGTH_LONG).show(); Log.e(TAG, String.format( "Could not save file with URI %s because of bad extension %s.", binaryPath, extension )); return; } destMediaPath = mInstanceFolder + System.currentTimeMillis() + customFileTag + "." + FileUtil.getExtension(binaryPath); File source = new File(binaryPath); newMedia = new File(destMediaPath); try { FileUtil.copyFile(source, newMedia); } catch (IOException e) { showToast("form.attachment.copy.fail"); Logger.exception(LogTypes.TYPE_MAINTENANCE, e); e.printStackTrace(); } } if (newMedia.exists()) { ContentValues values = new ContentValues(6); values.put(MediaStore.Audio.Media.TITLE, newMedia.getName()); values.put(MediaStore.Audio.Media.DISPLAY_NAME, newMedia.getName()); values.put(MediaStore.Audio.Media.DATE_ADDED, System.currentTimeMillis()); values.put(MediaStore.Audio.Media.DATA, newMedia.getAbsolutePath()); Uri mediaUri = getContext().getContentResolver().insert(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, values); String mediaUriString = mediaUri == null ? "null" : mediaUri.toString(); Log.i(TAG, "Inserting media returned uri = " + mediaUriString); showToast("form.attachment.success"); } else { Log.e(TAG, "Inserting media file FAILED"); } mBinaryName = newMedia.getName(); }