我正在使用相机意图创建 jpg 图像,但我无法随意命名它们。我正在使用以下代码:
private File createImageFile() throws IOException {
// Create an image file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = JPEG_FILE_PREFIX + timeStamp+ "_";
File image = File.createTempFile(
imageFileName,
JPEG_FILE_SUFFIX,
getAlbumDir()
);
return image;
}
private File getAlbumDir() {
File storageDir = null;
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
storageDir = new File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES), getString(R.string.album_name));
if (storageDir != null) {
if (! storageDir.mkdirs()) {
if (! storageDir.exists()){
// Log.d(TAG, "failed to create directory CameraSample");
return null;
}
}
}
} else {
// Log.v(getString(R.string.app_name),
//"External storage is not mounted READ/WRITE.");
}
return storageDir;
} // end getAlbumDir()
每个图片名称包含 JPEG_FILE_PREFIX、时间戳、JPEG_FILE_SUFFIX 但“|”之间还有另一个数字字符串 和JPEG_FILE_SUFFIX:1238385200。所以文件名就像:prefix_20131106_102238_1238385200.JPG
我可以删除该数字字符串吗?如何删除?谢谢大家