8
0
mirror of https://gitee.com/shuto/customCamera.git synced 2026-05-21 00:00:01 +08:00

Merge pull request #89 from geneanet/issue/82-error-store-picture-folder-not-exist

Create the directory for storage the picture in gallery if it doesn't exist.
This commit is contained in:
Christophe Boucaut
2015-07-10 09:39:53 +02:00
@@ -774,14 +774,26 @@ public class CameraActivity extends Activity {
// Get path picture to storage.
String pathPicture = Environment.getExternalStorageDirectory()
.getPath() + "/" + Environment.DIRECTORY_DCIM + "/Camera/";
pathPicture = pathPicture
+ String.format("%d.jpeg", System.currentTimeMillis());
// Create the directory if it doesn't exist.
File galleryDirectory = new File(pathPicture);
boolean directoryExist = galleryDirectory.exists();
if (!directoryExist) {
directoryExist = galleryDirectory.mkdirs();
}
if (directoryExist) {
pathPicture = pathPicture
+ String.format("%d.jpeg", System.currentTimeMillis());
// Write data in file.
FileOutputStream outStream = new FileOutputStream(pathPicture);
outStream.write(data);
data = null;
outStream.close();
// Write data in file.
FileOutputStream outStream = new FileOutputStream(pathPicture);
outStream.write(data);
data = null;
outStream.close();
} else {
Log.e("customCamera", "The directory for storage the picture in the gallery doesn't exist and his creation is failed.");
}
}
// Return to success & finish current activity.