0

im using the camera intent in my application but now i want to save the picture to a folder on my sdcard that goes right but he also saves it in my Camera album...

dir = new File(Environment.getExternalStorageDirectory() + "/myAlbum");
            if (!dir.exists()) {

                if (dir.mkdir()) {

                }
            }

            imageFilePath = dir + File.separator + Long.toString(System.currentTimeMillis() / 1000L) + ".jpg";
            originalFile = new File(imageFilePath);
            imageFileUri = Uri.fromFile(originalFile); // convert path to Uri
            Intent it = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            it.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageFileUri);
            startActivityForResult(it, REQUEST_IMAGE_CAPTURE);

does anyone know how to prevent this?

EDIT:

what i mean is: the picture is saving in /myAlbum but also in: /DCIM/Camera and i dont want the picture in the Camera folder

Rikkert09
  • 190
  • 1
  • 1
  • 11
  • your try to save the image in `/myAlbum` , change it. – prakash Oct 14 '14 at 10:03
  • that is what i want.. i want to save it in `/myAlbum` but he also saves it in the Camera album and that is what i dont want @prakash – Rikkert09 Oct 14 '14 at 10:07
  • try this link:http://stackoverflow.com/questions/14421694/taking-pictures-with-camera-android-programmatically – prakash Oct 14 '14 at 10:15

1 Answers1

0

I found an answer, now when i take a picture i delete the last taken photo from the /DCIM/Camera

with this code:

private void deleteLatestPicture() {

    File f = new File(Environment.getExternalStorageDirectory() + "/DCIM/Camera" );

    File [] files = f.listFiles();

    Arrays.sort(files, new Comparator<Object>() {
        public int compare(Object o1, Object o2) {

            if (((File) o1).lastModified() > ((File) o2).lastModified()) {
                return -1;
            } else if (((File) o1).lastModified() < ((File) o2).lastModified()) {
                return 1;
            } else {
                return 0;
            }
        }
    });

    files[0].delete();
}

i found the answer here: answer

Community
  • 1
  • 1
Rikkert09
  • 190
  • 1
  • 1
  • 11