I have the following code in an Android activity where I am trying to save an image with a custom file name.
I tried copying code for this from the top answer on this post: Android - Taking photos and saving them with a custom name to a custom destination via Intent
My code is below:
//camera stuff
Intent imageIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
//folder stuff
File imagesFolder = new File(Environment.getExternalStorageDirectory(), "MyImages");
imagesFolder.mkdirs();
File image = new File(imagesFolder, "QR_" + timeStamp + ".png");
Uri uriSavedImage = Uri.fromFile(image);
imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
Log.d(LOG_TAG, "writing photo to: " + uriSavedImage.toString());
startActivityForResult(imageIntent, 1);
When I run this activity, it shows a picture on the screen, I have to tap the touchpad to accept (this is running on Glass), and it prints the following in DDMS:
writing photo to: file:///mnt/sdcard/MyImages/QR_20140106_181934.jpg
However, when I check that directory in the file explorer through DDMS, it is empty. It successfully created the directory MyImages but didn't save any file in that directory.
Instead, it has created the following file with the image I just took: /mnt/sdcard/DCIM/Camera/20140106_181935_635.jpg
So it captures the correct image but just ignores where I told it to save it. Any ideas what I'm doing wrong?